Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2020-10-28 05:57:24 +0300
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2020-11-07 18:31:26 +0300
commita66fb45c0b19c9f6fce55f06919562e99ceb1d6f (patch)
treefcbc9360ab980c4b313b3723eb0f4011754466e9 /lib/private/Files/View.php
parentcad2369e0b0d9619b1c715e2912f68de07e7de1e (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/private/Files/View.php')
-rw-r--r--lib/private/Files/View.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index 16074a89ca8..fba412c37d4 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -665,7 +665,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 */
[$storage, $internalPath] = $this->resolvePath($path);