Unlock files even if an exception occurs

Signed-off-by: Kristof Hamann <korelstar@users.noreply.github.com>
This commit is contained in:
Kristof Hamann 2017-11-12 11:56:43 +01:00
parent 55f6a32097
commit c44126abb5
1 changed files with 87 additions and 82 deletions

View File

@ -739,10 +739,6 @@ class View {
$this->lockFile($path1, ILockingProvider::LOCK_SHARED, true);
try {
$this->lockFile($path2, ILockingProvider::LOCK_SHARED, true);
} catch (LockedException $e) {
$this->unlockFile($path1, ILockingProvider::LOCK_SHARED);
throw $e;
}
$run = true;
if ($this->shouldEmitHooks($path1) && (Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2))) {
@ -770,6 +766,7 @@ class View {
$internalPath2 = $mount2->getInternalPath($absolutePath2);
$this->changeLock($path1, ILockingProvider::LOCK_EXCLUSIVE, true);
try {
$this->changeLock($path2, ILockingProvider::LOCK_EXCLUSIVE, true);
if ($internalPath1 === '' and $mount1 instanceof MoveableMount) {
@ -805,8 +802,12 @@ class View {
}
}
} catch (\Exception $e) {
throw $e;
} finally {
$this->changeLock($path1, ILockingProvider::LOCK_SHARED, true);
$this->changeLock($path2, ILockingProvider::LOCK_SHARED, true);
}
if ((Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2)) && $result !== false) {
if ($this->shouldEmitHooks()) {
@ -825,9 +826,13 @@ class View {
}
}
}
} catch (\Exception $e) {
throw $e;
} finally {
$this->unlockFile($path1, ILockingProvider::LOCK_SHARED, true);
$this->unlockFile($path2, ILockingProvider::LOCK_SHARED, true);
}
}
return $result;
}