From 332e534f0a32f86e28b322a99f487b4fc994d6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Villaf=C3=A1=C3=B1ez?= Date: Tue, 23 Mar 2021 15:00:55 +0100 Subject: [PATCH] Fix warning about an ignored lock release --- apps/dav/lib/Connector/Sabre/LockPlugin.php | 23 +++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/LockPlugin.php b/apps/dav/lib/Connector/Sabre/LockPlugin.php index a017fc4ea0f..245f177cded 100644 --- a/apps/dav/lib/Connector/Sabre/LockPlugin.php +++ b/apps/dav/lib/Connector/Sabre/LockPlugin.php @@ -43,6 +43,8 @@ class LockPlugin extends ServerPlugin { */ private $server; + private $missedLocks = []; + /** * {@inheritdoc} */ @@ -59,9 +61,15 @@ public function getLock(RequestInterface $request) { if ($request->getMethod() !== 'PUT' || \OC_FileChunking::isWebdavChunk()) { return; } + + $requestedPath = $request->getPath(); try { - $node = $this->server->tree->getNodeForPath($request->getPath()); + $node = $this->server->tree->getNodeForPath($requestedPath); } catch (NotFound $e) { + if (!isset($this->missedLocks[$requestedPath])) { + $this->missedLocks[$requestedPath] = 0; + } + $this->missedLocks[$requestedPath]++; return; } if ($node instanceof Node) { @@ -77,8 +85,19 @@ public function releaseLock(RequestInterface $request) { if ($request->getMethod() !== 'PUT' || \OC_FileChunking::isWebdavChunk()) { return; } + + $requestedPath = $request->getPath(); + if (isset($this->missedLocks[$requestedPath])) { + // don't bother to unlock if we couldn't lock + $this->missedLocks[$requestedPath]--; + if ($this->missedLocks[$requestedPath] === 0) { + unset($this->missedLocks[$requestedPath]); + } + return; + } + try { - $node = $this->server->tree->getNodeForPath($request->getPath()); + $node = $this->server->tree->getNodeForPath($requestedPath); } catch (NotFound $e) { return; }