Skip to content

Commit

Permalink
Merge pull request #5947 from nextcloud/perf/node-by-id
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl authored Jun 26, 2024
2 parents e1e02a5 + 63bee14 commit 6cb4f07
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Service/DocumentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,14 @@ public function getFileById(int $fileId, ?string $userId = null): File {
throw new NotFoundException();
}

// We currently don't know the path nor care about which file mount it is when getting by id
// therefore we can take a shortcut on the cached node if we have edit permissions on that
$file = $userFolder->getFirstNodeById($fileId);
if ($file instanceof File && $file->getPermissions() & Constants::PERMISSION_UPDATE) {
return $file;
}

// Ideally we'd optimize this part in the future by storing the path and getting the acutal target directly
$files = $userFolder->getById($fileId);
if (count($files) === 0) {
throw new NotFoundException();
Expand Down

0 comments on commit 6cb4f07

Please sign in to comment.