diff options
author | Robin Appelman <robin@icewind.nl> | 2018-05-04 18:05:46 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-05-23 20:05:54 +0200 |
commit | 874e3129805ddec8d559c497d679116475bc6c67 (patch) | |
tree | bd95278b8c67540f5f61f9211d20ce8c56ef6515 /lib | |
parent | 2f059d1caf006253ccfa9334702f86469cc3a3c8 (diff) | |
download | nextcloud-server-874e3129805ddec8d559c497d679116475bc6c67.tar.gz nextcloud-server-874e3129805ddec8d559c497d679116475bc6c67.zip |
cleanup locks in scanner on error
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Cache/Scanner.php | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index a6adccbb4e2..02f30922384 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -332,15 +332,18 @@ class Scanner extends BasicEmitter implements IScanner { $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } - $data = $this->scanFile($path, $reuse, -1, null, $lock); - if ($data and $data['mimetype'] === 'httpd/unix-directory') { - $size = $this->scanChildren($path, $recursive, $reuse, $data['fileid'], $lock); - $data['size'] = $size; - } - if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { - $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); - $this->storage->releaseLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); + try { + $data = $this->scanFile($path, $reuse, -1, null, $lock); + if ($data and $data['mimetype'] === 'httpd/unix-directory') { + $size = $this->scanChildren($path, $recursive, $reuse, $data['fileid'], $lock); + $data['size'] = $size; + } + } finally { + if ($lock) { + if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); + $this->storage->releaseLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); + } } } return $data; |