cleanup locks in scanner on error

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2018-05-04 18:05:46 +02:00
parent fb296342b9
commit 63caf331e5
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
1 changed files with 12 additions and 9 deletions

View File

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