Skip to content

Commit

Permalink
Merge pull request #3297 from nextcloud/fix/trashbackend/delete-check…
Browse files Browse the repository at this point in the history
…s-stable27
  • Loading branch information
provokateurin authored Sep 30, 2024
2 parents 97fc905 + a175fff commit 08a5928
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 @@ -197,13 +197,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());
Expand Down

0 comments on commit 08a5928

Please sign in to comment.