Skip to content

Commit

Permalink
Improve code readability and add comments
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Dec 4, 2023
1 parent 44490d3 commit 1bab814
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/ACL/ACLManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,23 @@ private function getRelevantPaths(string $path): array {
$paths = [];
$fromTrashbin = str_starts_with($path, '__groupfolders/trash/');
if ($fromTrashbin) {
$rootName = explode('/', $path, 5)[3];
$rootName = substr($rootName, 0, strrpos($rootName, '.d'));
/* Exploded path will look like ["__groupfolders", "trash", "1", "folderName.d2345678", "rest/of/the/path.txt"] */
$rootTrashedItemName = explode('/', $path, 5)[3];
/* Remove the date part */
$rootTrashedItemName = substr($rootTrashedItemName, 0, strrpos($rootTrashedItemName, '.d'));
}
while ($path !== '') {
$paths[] = $path;
$path = dirname($path);
if ($fromTrashbin && ($path === '__groupfolders/trash')) {
$trashItemRow = $this->trashManager->getTrashItemByFileName($rootName);
/* We are in trash and hit the root folder, continue looking for ACLs on parent folders in original location */
$trashItemRow = $this->trashManager->getTrashItemByFileName($rootTrashedItemName);
$path = dirname('__groupfolders/' . $trashItemRow['folder_id'] . '/' . $trashItemRow['original_location']);
$fromTrashbin = false;
} elseif ($path === '.' || $path === '/') {
continue;
}

if ($path === '.' || $path === '/') {
$path = '';
}
}
Expand Down

0 comments on commit 1bab814

Please sign in to comment.