From ddfdcfd8b19e444529759abc64382b213cd628f0 Mon Sep 17 00:00:00 2001 From: micbar Date: Wed, 1 Aug 2018 11:26:06 +0200 Subject: [PATCH] Set the exclusive file lock earlier. --- apps/dav/lib/Connector/Sabre/File.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 2e02dd07bb42..e57201745196 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -188,6 +188,16 @@ public function put($data) { // because we have no clue about the cause we can only throw back a 500/Internal Server Error throw new Exception('Could not write file contents'); } + + try { + $this->changeLock(ILockingProvider::LOCK_EXCLUSIVE); + } catch (LockedException $e) { + if ($needsPartFile) { + $partStorage->unlink($internalPartPath); + } + throw new FileLocked($e->getMessage(), $e->getCode(), $e); + } + list($count, $result) = \OC_Helper::streamCopy($data, $target); \fclose($target); @@ -227,15 +237,6 @@ public function put($data) { $run = true; } - try { - $this->changeLock(ILockingProvider::LOCK_EXCLUSIVE); - } catch (LockedException $e) { - if ($needsPartFile) { - $partStorage->unlink($internalPartPath); - } - throw new FileLocked($e->getMessage(), $e->getCode(), $e); - } - if ($needsPartFile) { // rename to correct path try {