Skip to content

Commit

Permalink
Changed locking to avoid exclusive lock during hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Aug 13, 2018
1 parent 08503ab commit 42dbf9b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ public function put($data) {
list($count, $result) = \OC_Helper::streamCopy($data, $target);
\fclose($target);

try {
$this->changeLock(ILockingProvider::LOCK_SHARED);
} catch (LockedException $e) {
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}

if (!self::isChecksumValid($partStorage, $internalPartPath)) {
throw new BadRequest('The computed checksum does not match the one received from the client.');
}
Expand Down Expand Up @@ -241,6 +247,15 @@ 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 42dbf9b

Please sign in to comment.