Skip to content

Commit

Permalink
feat: Only getShares for provided types
Browse files Browse the repository at this point in the history
With the types filter in place (1e7f53e) we should avoid,
fetching all shares.

Preventing potential N+1s

Signed-off-by: nfebe <[email protected]>
  • Loading branch information
nfebe committed Mar 7, 2025
1 parent a57e88a commit cca22cb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ private function getFormattedShares(
return $this->getSharesInDir($node);
}

$shares = $this->getSharesFromNode($viewer, $node, $reShares);
$shares = $this->getSharesFromNode($viewer, $node, $reShares, $types);

$known = $formatted = $miniFormatted = [];
$resharingRight = false;
Expand Down Expand Up @@ -1883,7 +1883,7 @@ private function getSciencemeshShareHelper() {
*
* @return IShare[]
*/
private function getSharesFromNode(string $viewer, $node, bool $reShares): array {
private function getSharesFromNode(string $viewer, $node, bool $reShares, array $limitToProviders = []): array {
$providers = [
IShare::TYPE_USER,
IShare::TYPE_GROUP,
Expand All @@ -1895,6 +1895,10 @@ private function getSharesFromNode(string $viewer, $node, bool $reShares): array
IShare::TYPE_SCIENCEMESH
];

if (count($limitToProviders) > 0) {
$providers = $limitToProviders;
}

// Should we assume that the (currentUser) viewer is the owner of the node !?
$shares = [];
foreach ($providers as $provider) {
Expand Down

0 comments on commit cca22cb

Please sign in to comment.