Skip to content

Commit

Permalink
fix(TreeMapper#isFolderSharedWithUser): Check full depth
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Sep 20, 2024
1 parent 93e8743 commit 3ae6a9d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/Db/TreeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1151,14 +1151,18 @@ public function isFolderSharedWithUser(int $folderId, string $userId): bool {
// noop
}

$ancestors = $this->findParentsOf(TreeMapper::TYPE_FOLDER, $folderId);// FIXME: This will not find ancestors
foreach ($ancestors as $ancestorFolder) {
try {
$this->sharedFolderMapper->findByFolderAndUser($ancestorFolder->getId(), $userId);
return true;
} catch (DoesNotExistException) {
// noop
try {
while ($ancestorFolder = $this->findParentOf(TreeMapper::TYPE_FOLDER, $folderId)) {
try {
$this->sharedFolderMapper->findByFolderAndUser($ancestorFolder->getId(), $userId);
return true;
} catch (DoesNotExistException) {
// noop
}
$folderId = $ancestorFolder->getId();
}
} catch (DoesNotExistException $e) {
// noop
}

return false;
Expand Down

0 comments on commit 3ae6a9d

Please sign in to comment.