Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[stable29] fix: improve handling of ACL rules in trashbin #3330

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/ACL/ACLManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,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 @@ -94,7 +94,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 @@ -104,7 +108,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
Loading