Skip to content

Commit e21f440

Browse files
authored
Merge pull request #16502 from nextcloud/bugfix/16474
Check the if we can actually access the storage cache for recent files
2 parents 8d8766d + e43b341 commit e21f440

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

lib/private/Files/Node/Folder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,13 @@ private function recentParse($result, $mountMap, $mimetypeLoader) {
442442
}, $result));
443443

444444
return array_values(array_filter($files, function (Node $node) {
445+
$cacheEntry = $node->getMountPoint()->getStorage()->getCache()->get($node->getId());
446+
if (!$cacheEntry) {
447+
return false;
448+
}
445449
$relative = $this->getRelativePath($node->getPath());
446-
return $relative !== null && $relative !== '/';
450+
return $relative !== null && $relative !== '/'
451+
&& ($cacheEntry->getPermissions() & \OCP\Constants::PERMISSION_READ) === \OCP\Constants::PERMISSION_READ;
447452
}));
448453
}
449454

tests/lib/Files/Node/FolderTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -810,13 +810,15 @@ public function testRecent() {
810810
'storage_mtime' => $baseTime,
811811
'mtime' => $baseTime,
812812
'mimetype' => 'text/plain',
813-
'size' => 3
813+
'size' => 3,
814+
'permissions' => \OCP\Constants::PERMISSION_ALL
814815
]);
815816
$id2 = $cache->put('bar/foo/old.txt', [
816817
'storage_mtime' => $baseTime - 100,
817818
'mtime' => $baseTime - 100,
818819
'mimetype' => 'text/plain',
819-
'size' => 3
820+
'size' => 3,
821+
'permissions' => \OCP\Constants::PERMISSION_READ
820822
]);
821823
$cache->put('bar/asd/outside.txt', [
822824
'storage_mtime' => $baseTime,
@@ -828,7 +830,8 @@ public function testRecent() {
828830
'storage_mtime' => $baseTime - 600,
829831
'mtime' => $baseTime - 600,
830832
'mimetype' => 'text/plain',
831-
'size' => 3
833+
'size' => 3,
834+
'permissions' => \OCP\Constants::PERMISSION_ALL
832835
]);
833836

834837
$node = new \OC\Files\Node\Folder($root, $view, $folderPath, $folderInfo);
@@ -871,21 +874,24 @@ public function testRecentFolder() {
871874
'storage_mtime' => $baseTime,
872875
'mtime' => $baseTime,
873876
'mimetype' => \OCP\Files\FileInfo::MIMETYPE_FOLDER,
874-
'size' => 3
877+
'size' => 3,
878+
'permissions' => 0
875879
]);
876880
$id2 = $cache->put('bar/foo/folder/bar.txt', [
877881
'storage_mtime' => $baseTime,
878882
'mtime' => $baseTime,
879883
'mimetype' => 'text/plain',
880884
'size' => 3,
881-
'parent' => $id1
885+
'parent' => $id1,
886+
'permissions' => \OCP\Constants::PERMISSION_ALL
882887
]);
883888
$id3 = $cache->put('bar/foo/folder/asd.txt', [
884889
'storage_mtime' => $baseTime - 100,
885890
'mtime' => $baseTime - 100,
886891
'mimetype' => 'text/plain',
887892
'size' => 3,
888-
'parent' => $id1
893+
'parent' => $id1,
894+
'permissions' => \OCP\Constants::PERMISSION_ALL
889895
]);
890896

891897
$node = new \OC\Files\Node\Folder($root, $view, $folderPath, $folderInfo);
@@ -934,7 +940,8 @@ public function testRecentJail() {
934940
'storage_mtime' => $baseTime,
935941
'mtime' => $baseTime,
936942
'mimetype' => 'text/plain',
937-
'size' => 3
943+
'size' => 3,
944+
'permissions' => \OCP\Constants::PERMISSION_ALL
938945
]);
939946
$cache->put('outside.txt', [
940947
'storage_mtime' => $baseTime - 100,

0 commit comments

Comments
 (0)