Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
In LockPlugin, only release a lock if it was acquired
When uploading new files, getNodeForPath() will not succeed
yet so the lock cannot be acquired.

In that case, don't try to unlock it either.

Signed-off-by: Jaakko Salo <[email protected]>
  • Loading branch information
jvsalo authored and backportbot[bot] committed Jul 6, 2020
commit d6df3a50cdc11c8b6e3d995a13fd1db116986d7f
13 changes: 13 additions & 0 deletions apps/dav/lib/Connector/Sabre/LockPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ class LockPlugin extends ServerPlugin {
*/
private $server;

/**
* State of the lock
*
* @var bool
*/
private $isLocked;

/**
* {@inheritdoc}
*/
Expand All @@ -66,10 +73,15 @@ public function getLock(RequestInterface $request) {
} catch (LockedException $e) {
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
$this->isLocked = true;
}
}

public function releaseLock(RequestInterface $request) {
// don't try to release the lock if we never locked one
if ($this->isLocked === false) {
return;
}
if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) {
return;
}
Expand All @@ -80,6 +92,7 @@ public function releaseLock(RequestInterface $request) {
}
if ($node instanceof Node) {
$node->releaseLock(ILockingProvider::LOCK_SHARED);
$this->isLocked = false;
}
}
}