From d5c3b5e8f90c623b51f57aad779d19eace71e475 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Wed, 11 Apr 2018 21:43:29 +0300 Subject: [PATCH] Keep fileId for deletedItems in a separate cache --- .../lib/DAV/FileCustomPropertiesBackend.php | 15 ++++++--------- apps/dav/lib/Tree.php | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/apps/dav/lib/DAV/FileCustomPropertiesBackend.php b/apps/dav/lib/DAV/FileCustomPropertiesBackend.php index 6988d51932e0..524d7dfaee8f 100644 --- a/apps/dav/lib/DAV/FileCustomPropertiesBackend.php +++ b/apps/dav/lib/DAV/FileCustomPropertiesBackend.php @@ -71,16 +71,13 @@ public function delete($path) { return; } - $node = $this->getNodeForPath($path); - if (is_null($node)) { - return; + $fileId = $this->tree->getDeletedItemFileId($path); + if ($fileId !== false) { + $statement = $this->connection->prepare(self::DELETE_BY_ID_STMT); + $statement->execute([$fileId]); + $this->offsetUnset($fileId); + $statement->closeCursor(); } - - $fileId = $node->getId(); - $statement = $this->connection->prepare(self::DELETE_BY_ID_STMT); - $statement->execute([$fileId]); - $this->offsetUnset($fileId); - $statement->closeCursor(); } /** diff --git a/apps/dav/lib/Tree.php b/apps/dav/lib/Tree.php index b3627d005a66..803b69f11a9c 100644 --- a/apps/dav/lib/Tree.php +++ b/apps/dav/lib/Tree.php @@ -31,6 +31,24 @@ * having to walk through every node and trigger unnecessary extra queries. */ class Tree extends \Sabre\DAV\Tree { + + protected $deletedItems = []; + + public function getDeletedItemFileId($path) { + if (isset($this->deletedItems[$path])) { + return $this->deletedItems[$path]; + } + return false; + } + + public function delete($path) { + $node = $this->getNodeForPath($path); + if (!is_null($node) && $node->getId()) { + $this->deletedItems[$path] = $node->getId(); + } + parent::delete($path); + } + /** * Returns the INode object for the requested path *