summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-05-23 22:57:42 +0200
committerGitHub <noreply@github.com>2018-05-23 22:57:42 +0200
commitfe20bb4b2709752a0269a5c496a1200b01ce0ce6 (patch)
treee48f1e82cf4a69d03e82a126894df0253422bf7d
parent56b8a889c16b1d57dc2fec9e36a86659b1f31e0d (diff)
parent874e3129805ddec8d559c497d679116475bc6c67 (diff)
downloadnextcloud-server-fe20bb4b2709752a0269a5c496a1200b01ce0ce6.tar.gz
nextcloud-server-fe20bb4b2709752a0269a5c496a1200b01ce0ce6.zip
Merge pull request #9566 from nextcloud/backport/9395/stable13
[stable13] cleanup locks in scanner on error
-rw-r--r--lib/private/Files/Cache/Scanner.php21
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;