Skip to content

Commit 59cda8e

Browse files
authored
Merge pull request #51296 from nextcloud/fileutils-files-by-user
fix: optimize FileUtils::getFilesByUser
2 parents eb59791 + 8edca98 commit 59cda8e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

core/Command/Info/FileUtils.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ public function getFilesByUser(FileInfo $file): array {
4646

4747
$mounts = $this->userMountCache->getMountsForFileId($id);
4848
$result = [];
49-
foreach ($mounts as $mount) {
50-
if (isset($result[$mount->getUser()->getUID()])) {
51-
continue;
52-
}
53-
54-
$userFolder = $this->rootFolder->getUserFolder($mount->getUser()->getUID());
55-
$result[$mount->getUser()->getUID()] = $userFolder->getById($id);
49+
foreach ($mounts as $cachedMount) {
50+
$mount = $this->rootFolder->getMount($cachedMount->getMountPoint());
51+
$cache = $mount->getStorage()->getCache();
52+
$cacheEntry = $cache->get($id);
53+
$node = $this->rootFolder->getNodeFromCacheEntryAndMount($cacheEntry, $mount);
54+
$result[$cachedMount->getUser()->getUID()][] = $node;
5655
}
5756

5857
return $result;

lib/private/Files/Node/Root.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,9 @@ public function getNodeFromCacheEntryAndMount(ICacheEntry $cacheEntry, IMountPoi
522522
$isDir = $info->getType() === FileInfo::TYPE_FOLDER;
523523
$view = new View('');
524524
if ($isDir) {
525-
return new Folder($this, $view, $path, $info, $parent);
525+
return new Folder($this, $view, $fullPath, $info, $parent);
526526
} else {
527-
return new File($this, $view, $path, $info, $parent);
527+
return new File($this, $view, $fullPath, $info, $parent);
528528
}
529529
}
530530
}

0 commit comments

Comments
 (0)