Skip to content

Commit

Permalink
Merge pull request #3332 from nextcloud/backport/acl-no-trash-item/27
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin authored Oct 14, 2024
2 parents f643647 + 6d467d0 commit dfeb43c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/ACL/ACLManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,8 @@ public function getPermissionsForTree(string $path): int {
return $permissions & $denyMask;
}, Constants::PERMISSION_ALL);
}

public function preloadRulesForFolder(string $path): void {
$this->ruleManager->getRulesForFilesByParent($this->user, $this->getRootStorageId(), $path);
}
}
9 changes: 7 additions & 2 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ public function listTrashFolder(ITrashItem $trashItem): array {
return [];
}
$content = $folder->getDirectoryListing();
return array_map(function (Node $node) use ($trashItem, $user) {
$this->aclManagerFactory->getACLManager($user)->preloadRulesForFolder($trashItem->getPath());
return array_values(array_filter(array_map(function (Node $node) use ($trashItem, $user) {
if (!$this->userHasAccessToPath($user, $trashItem->getPath() . '/' . $node->getName())) {
return null;
}
return new GroupTrashItem(
$this,
$trashItem->getOriginalLocation() . '/' . $node->getName(),
Expand All @@ -105,7 +109,7 @@ public function listTrashFolder(ITrashItem $trashItem): array {
$user,
$trashItem->getGroupFolderMountPoint()
);
}, $content);
}, $content)));
}

/**
Expand Down Expand Up @@ -330,6 +334,7 @@ private function getTrashForFolders(IUser $user, array $folders): array {
$mountPoint = $folder['mount_point'];
$trashFolder = $this->getTrashFolder($folderId);
$content = $trashFolder->getDirectoryListing();
$this->aclManagerFactory->getACLManager($user)->preloadRulesForFolder($trashFolder->getPath());
foreach ($content as $item) {
/** @var \OC\Files\Node\Node $item */
$pathParts = pathinfo($item->getName());
Expand Down

0 comments on commit dfeb43c

Please # to comment.