From f4de29e0d0574069dd63555d8a2466b2b97684ef Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 16 Jul 2024 16:03:27 +0200 Subject: [PATCH] fix: improve handling of ACL rules in trashbin Signed-off-by: Robin Appelman --- lib/ACL/ACLManager.php | 4 ++++ lib/Trash/TrashBackend.php | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/ACL/ACLManager.php b/lib/ACL/ACLManager.php index 00055f14a..8bdde8c86 100644 --- a/lib/ACL/ACLManager.php +++ b/lib/ACL/ACLManager.php @@ -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); + } } diff --git a/lib/Trash/TrashBackend.php b/lib/Trash/TrashBackend.php index ba63eb9bc..7ca23d3e8 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -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(), @@ -105,7 +109,7 @@ public function listTrashFolder(ITrashItem $trashItem): array { $user, $trashItem->getGroupFolderMountPoint() ); - }, $content); + }, $content))); } /** @@ -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());