Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 10 additions & 11 deletions lib/private/Files/Node/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,15 @@ public function getById($id) {
return [];
}

// we only need to get the cache info once, since all mounts we found point to the same storage

$mount = $folderMounts[$mountsContainingFile[0]->getMountPoint()];
$cacheEntry = $mount->getStorage()->getCache()->get((int)$id);
if (!$cacheEntry) {
return [];
}
// cache jails will hide the "true" internal path
$internalPath = ltrim($mountsContainingFile[0]->getRootInternalPath() . '/' . $cacheEntry->getPath(), '/');

$nodes = array_map(function (ICachedMountInfo $cachedMountInfo) use ($cacheEntry, $folderMounts, $internalPath) {
$nodes = array_map(function (ICachedMountInfo $cachedMountInfo) use ($folderMounts, $id) {
$mount = $folderMounts[$cachedMountInfo->getMountPoint()];
$cacheEntry = $mount->getStorage()->getCache()->get((int)$id);
if (!$cacheEntry) {
return null;
}

// cache jails will hide the "true" internal path
$internalPath = ltrim($cachedMountInfo->getRootInternalPath() . '/' . $cacheEntry->getPath(), '/');
$pathRelativeToMount = substr($internalPath, strlen($cachedMountInfo->getRootInternalPath()));
$pathRelativeToMount = ltrim($pathRelativeToMount, '/');
$absolutePath = $cachedMountInfo->getMountPoint() . $pathRelativeToMount;
Expand All @@ -323,6 +320,8 @@ public function getById($id) {
));
}, $mountsContainingFile);

$nodes = array_filter($nodes);

return array_filter($nodes, function (Node $node) {
return $this->getRelativePath($node->getPath());
});
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Files/Node/FolderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ public function testGetByIdMultipleStorages() {

$fileInfo = new CacheEntry(['path' => 'foo/qwerty', 'mimetype' => 'text/plain'], null);

$storage->expects($this->once())
$storage->expects($this->exactly(2))
->method('getCache')
->will($this->returnValue($cache));

Expand Down