Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: optimize FileUtils::getFilesByUser #51296

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions core/Command/Info/FileUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

/**
* @param FileInfo $file
* @return array<string, Node[]>

Check failure on line 37 in core/Command/Info/FileUtils.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidReturnType

core/Command/Info/FileUtils.php:37:13: InvalidReturnType: The declared return type 'array<string, array<array-key, OCP\Files\Node>>' for OC\Core\Command\Info\FileUtils::getFilesByUser is incorrect, got 'array<string, OCP\Files\Node>' (see https://psalm.dev/011)
* @throws \OCP\Files\NotPermittedException
* @throws \OC\User\NoUserException
*/
Expand All @@ -46,16 +46,19 @@

$mounts = $this->userMountCache->getMountsForFileId($id);
$result = [];
foreach ($mounts as $mount) {
if (isset($result[$mount->getUser()->getUID()])) {
foreach ($mounts as $cachedMount) {
if (isset($result[$cachedMount->getUser()->getUID()])) {
continue;
}

$userFolder = $this->rootFolder->getUserFolder($mount->getUser()->getUID());
$result[$mount->getUser()->getUID()] = $userFolder->getById($id);
$mount = $this->rootFolder->getMount($cachedMount->getMountPoint());
$cache = $mount->getStorage()->getCache();
$cacheEntry = $cache->get($id);
$node = $this->rootFolder->getNodeFromCacheEntryAndMount($cacheEntry, $mount);
$result[$cachedMount->getUser()->getUID()] = $node;
}

return $result;

Check failure on line 61 in core/Command/Info/FileUtils.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidReturnStatement

core/Command/Info/FileUtils.php:61:10: InvalidReturnStatement: The inferred type 'array<string, OCP\Files\Node>' does not match the declared return type 'array<string, array<array-key, OCP\Files\Node>>' for OC\Core\Command\Info\FileUtils::getFilesByUser (see https://psalm.dev/128)
}

/**
Expand Down
Loading