Skip to content

Commit

Permalink
Merge pull request #3299 from nextcloud/fix/trashbackend/delete-check…
Browse files Browse the repository at this point in the history
…s-stable25
  • Loading branch information
provokateurin authored Sep 30, 2024
2 parents d5ecf9a + ad0c99e commit dba363a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,20 @@ public function removeItem(ITrashItem $item) {
if ($node === null) {
throw new NotFoundException();
}
if ($node->getStorage()->unlink($node->getInternalPath()) === false) {
throw new \Exception('Failed to remove item from trashbin');
}

if (!$this->userHasAccessToPath($item->getUser(), $folderId . '/' . $item->getOriginalLocation(), Constants::PERMISSION_DELETE)) {
throw new NotPermittedException();
}

$folderPermissions = $this->folderManager->getFolderPermissionsForUser($item->getUser(), (int)$folderId);
if (($folderPermissions & Constants::PERMISSION_DELETE) !== Constants::PERMISSION_DELETE) {
throw new NotPermittedException();
}

if ($node->getStorage()->unlink($node->getInternalPath()) === false) {
throw new \Exception('Failed to remove item from trashbin');
}

$node->getStorage()->getCache()->remove($node->getInternalPath());
if ($item->isRootItem()) {
$this->trashManager->removeItem((int)$folderId, $item->getName(), $item->getDeletedTime());
Expand Down

0 comments on commit dba363a

Please sign in to comment.