Skip to content

Commit

Permalink
also handle expired pre-write shared lock on dav upload when not usin…
Browse files Browse the repository at this point in the history
…g part files

Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Feb 25, 2022
1 parent d521583 commit a4387f7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,23 @@ public function put($data) {
[$storage, $internalPath] = $this->fileView->resolvePath($this->path);
try {
if (!$needsPartFile) {
$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
try {
$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
} catch (LockedException $e) {
// 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 $ex) {
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
}
}

if (!is_resource($data)) {
Expand Down

0 comments on commit a4387f7

Please sign in to comment.