Merge pull request #51296 from nextcloud/fileutils-files-by-user

fix: optimize FileUtils::getFilesByUser
pull/51384/head
Robin Appelman 2025-03-10 19:26:24 +07:00 committed by GitHub
commit 59cda8e9fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 9 deletions

@ -46,13 +46,12 @@ class FileUtils {
$mounts = $this->userMountCache->getMountsForFileId($id);
$result = [];
foreach ($mounts as $mount) {
if (isset($result[$mount->getUser()->getUID()])) {
continue;
}
$userFolder = $this->rootFolder->getUserFolder($mount->getUser()->getUID());
$result[$mount->getUser()->getUID()] = $userFolder->getById($id);
foreach ($mounts as $cachedMount) {
$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;

@ -522,9 +522,9 @@ class Root extends Folder implements IRootFolder {
$isDir = $info->getType() === FileInfo::TYPE_FOLDER;
$view = new View('');
if ($isDir) {
return new Folder($this, $view, $path, $info, $parent);
return new Folder($this, $view, $fullPath, $info, $parent);
} else {
return new File($this, $view, $path, $info, $parent);
return new File($this, $view, $fullPath, $info, $parent);
}
}
}