diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2020-10-28 05:57:24 +0300 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-11-12 22:07:46 +0300 |
commit | a428cfeb2627769c8b9aed70eb6cac18080d17e5 (patch) | |
tree | 80629a46964fd6f399bf3efec25569a464388465 /lib | |
parent | dafd09d30b96d372272317460dec2fc473ebf1ee (diff) |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/View.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 9aaa37feee9..6ce13d9ca51 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -663,7 +663,13 @@ class View { return false; } - $this->changeLock($path, ILockingProvider::LOCK_EXCLUSIVE); + try { + $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 */ list($storage, $internalPath) = $this->resolvePath($path); |