Unlock when promoting to exclusive lock fails
In certain cases changeLock to EXCLUSIVE fails and throws LockedException. This leaves the file locked as SHARED in file_put_contents, which prevents retrying (because on second call file_put_contents takes another SHARED lock on the same file, and changeLock doesn't allow more than a single SHARED lock to promote to EXCLUSIVE). To avoid this case, we catch the LockedException and unlock before re-throwing. Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
parent
cad2369e0b
commit
a66fb45c0b
|
@ -665,7 +665,13 @@ class View {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$this->changeLock($path, ILockingProvider::LOCK_EXCLUSIVE);
|
$this->changeLock($path, ILockingProvider::LOCK_EXCLUSIVE);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Release the shared lock before throwing.
|
||||||
|
$this->unlockFile($path, ILockingProvider::LOCK_SHARED);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
/** @var \OC\Files\Storage\Storage $storage */
|
/** @var \OC\Files\Storage\Storage $storage */
|
||||||
[$storage, $internalPath] = $this->resolvePath($path);
|
[$storage, $internalPath] = $this->resolvePath($path);
|
||||||
|
|
Loading…
Reference in New Issue