diff --git a/lib/Trash/TrashBackend.php b/lib/Trash/TrashBackend.php index 6c98c73e3..44f452592 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -196,13 +196,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(), $item->getPath(), 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());