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:
authorRobin Appelman <robin@icewind.nl>2019-11-13 16:54:22 +0300
committerRobin Appelman <robin@icewind.nl>2019-11-13 16:54:22 +0300
commit2e97e8bf84af63cd1ce55eb0694811f7b3d45e34 (patch)
tree7501488d74773cdcfecfb57555224ace0a573b63 /apps/dav/lib/Connector/Sabre/File.php
parentd9204f61ead5f5c95cbef21a5d6fc40ac2d1861a (diff)
re-acquired expired shared locks on large file uploads
during large file uploads, the shared lock that we get at the begining can expire leading to locked errors later on, instead of erroring, try to re-get the lock Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/dav/lib/Connector/Sabre/File.php')
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index dd25b046bcf..2d019b46b6a 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -252,10 +252,22 @@ class File extends Node implements IFile {
try {
$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
} catch (LockedException $e) {
- if ($needsPartFile) {
- $partStorage->unlink($internalPartPath);
+ // during very large uploads, the shared lock we got at the start might have been expired
+ // meaning that the above lock can fail not just only because somebody else got a shared lock
+ // or because there is no existing shared lock to make exclusive
+ //
+ // Thus we try to get a new exclusive lock, if the original lock failed because of a different shared
+ // lock this will still fail, if our original shared lock expired the new lock will be successful and
+ // the entire operation will be safe
+
+ try {
+ $this->acquireLock(ILockingProvider::LOCK_EXCLUSIVE);
+ } catch (LockedException $e) {
+ if ($needsPartFile) {
+ $partStorage->unlink($internalPartPath);
+ }
+ throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
- throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
// rename to correct path