diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-07-06 14:06:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-06 14:06:41 +0200 |
commit | e878c0a054ac86e1a8791306486a826d9231f35f (patch) | |
tree | dee0911d70fd0b113a4d1ed4cb17c09b1e18069d /apps/dav | |
parent | d72d9ff1f48eb282101c29aeea2a13c7f1368f8f (diff) | |
parent | 6886b46ee28addba626cc1e8a87181ca2800de25 (diff) | |
download | nextcloud-server-e878c0a054ac86e1a8791306486a826d9231f35f.tar.gz nextcloud-server-e878c0a054ac86e1a8791306486a826d9231f35f.zip |
Merge pull request #21074 from jvsalo/shared-lock-multi-release
Fix releasing a shared lock multiple times
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/LockPlugin.php | 14 |
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; } } } |