Merge pull request #9567 from nextcloud/backport/9395/stable12

[stable12] cleanup locks in scanner on error
This commit is contained in:
Roeland Jago Douma 2018-05-23 23:04:06 +02:00 committed by GitHub
commit 3ebed2b9e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 9 deletions

View File

@ -319,17 +319,20 @@ class Scanner extends BasicEmitter implements IScanner {
$this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
} }
} }
try {
$data = $this->scanFile($path, $reuse, -1, null, $lock); $data = $this->scanFile($path, $reuse, -1, null, $lock);
if ($data and $data['mimetype'] === 'httpd/unix-directory') { if ($data and $data['mimetype'] === 'httpd/unix-directory') {
$size = $this->scanChildren($path, $recursive, $reuse, $data['fileid'], $lock); $size = $this->scanChildren($path, $recursive, $reuse, $data['fileid'], $lock);
$data['size'] = $size; $data['size'] = $size;
} }
} finally {
if ($lock) { if ($lock) {
if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
$this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
$this->storage->releaseLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); $this->storage->releaseLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider);
} }
} }
}
return $data; return $data;
} }