Skip to content

Commit

Permalink
Keep fileId for deletedItems in a separate cache
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed Apr 11, 2018
1 parent 74e4712 commit d5c3b5e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
15 changes: 6 additions & 9 deletions apps/dav/lib/DAV/FileCustomPropertiesBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
18 changes: 18 additions & 0 deletions apps/dav/lib/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit d5c3b5e

Please sign in to comment.