summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorJaakko Salo <jaakkos@gmail.com>2020-05-24 20:03:48 +0300
committerJaakko Salo <jaakko@meetiqm.com>2020-05-24 20:26:38 +0300
commit6886b46ee28addba626cc1e8a87181ca2800de25 (patch)
tree7f6bb3e4278b63fa40a7f748a8566f756c9b44fb /apps/dav
parentb7dd278e24685fbec34a95b797c204f4a1d53064 (diff)
downloadnextcloud-server-6886b46ee28addba626cc1e8a87181ca2800de25.tar.gz
nextcloud-server-6886b46ee28addba626cc1e8a87181ca2800de25.zip
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 <jaakkos@gmail.com>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Connector/Sabre/LockPlugin.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/apps/dav/lib/Connector/Sabre/LockPlugin.php b/apps/dav/lib/Connector/Sabre/LockPlugin.php
index 7c07f45fc79..bdb681be8da 100644
--- a/apps/dav/lib/Connector/Sabre/LockPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/LockPlugin.php
@@ -42,12 +42,20 @@ class LockPlugin extends ServerPlugin {
private $server;
/**
+ * State of the lock
+ *
+ * @var bool
+ */
+ private $isLocked;
+
+ /**
* {@inheritdoc}
*/
public function initialize(\Sabre\DAV\Server $server) {
$this->server = $server;
$this->server->on('beforeMethod:*', [$this, 'getLock'], 50);
$this->server->on('afterMethod:*', [$this, 'releaseLock'], 50);
+ $this->isLocked = false;
}
public function getLock(RequestInterface $request) {
@@ -67,10 +75,15 @@ class LockPlugin extends ServerPlugin {
} 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;
}
@@ -81,6 +94,7 @@ class LockPlugin extends ServerPlugin {
}
if ($node instanceof Node) {
$node->releaseLock(ILockingProvider::LOCK_SHARED);
+ $this->isLocked = false;
}
}
}