Skip to content

Commit

Permalink
Set the exclusive file lock earlier.
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Aug 2, 2018
1 parent 3eee971 commit ddfdcfd
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ddfdcfd

Please sign in to comment.