Skip to content

Commit ef8bc9e

Browse files
committed
also handle expired pre-write shared lock on dav upload when not using part files
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent c2d0e61 commit ef8bc9e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

apps/dav/lib/Connector/Sabre/File.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,23 @@ public function put($data) {
173173
[$storage, $internalPath] = $this->fileView->resolvePath($this->path);
174174
try {
175175
if (!$needsPartFile) {
176-
$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
176+
try {
177+
$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
178+
} catch (LockedException $e) {
179+
// during very large uploads, the shared lock we got at the start might have been expired
180+
// meaning that the above lock can fail not just only because somebody else got a shared lock
181+
// or because there is no existing shared lock to make exclusive
182+
//
183+
// Thus we try to get a new exclusive lock, if the original lock failed because of a different shared
184+
// lock this will still fail, if our original shared lock expired the new lock will be successful and
185+
// the entire operation will be safe
186+
187+
try {
188+
$this->acquireLock(ILockingProvider::LOCK_EXCLUSIVE);
189+
} catch (LockedException $ex) {
190+
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
191+
}
192+
}
177193
}
178194

179195
if (!is_resource($data)) {

0 commit comments

Comments
 (0)