From f1f755740d90c20fb37ee8a86ea2c20fac03cb55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 22 Jul 2019 16:41:15 +0200 Subject: [PATCH 1/2] Check the if we can actually access the storage cache for recent files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/Files/Node/Folder.php | 4 ++++ tests/lib/Files/Node/FolderTest.php | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index b0569a24aa..7f908a757a 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -442,6 +442,10 @@ class Folder extends Node implements \OCP\Files\Folder { }, $result)); return array_values(array_filter($files, function (Node $node) { + $cacheEntry = $node->getMountPoint()->getStorage()->getCache()->get($node->getId()); + if (!$cacheEntry) { + return false; + } $relative = $this->getRelativePath($node->getPath()); return $relative !== null && $relative !== '/'; })); diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index e1ee96c37e..061b9419f3 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -861,13 +861,15 @@ class FolderTest extends NodeTest { 'storage_mtime' => $baseTime, 'mtime' => $baseTime, 'mimetype' => 'text/plain', - 'size' => 3 + 'size' => 3, + 'permissions' => \OCP\Constants::PERMISSION_ALL ]); $id2 = $cache->put('bar/foo/old.txt', [ 'storage_mtime' => $baseTime - 100, 'mtime' => $baseTime - 100, 'mimetype' => 'text/plain', - 'size' => 3 + 'size' => 3, + 'permissions' => \OCP\Constants::PERMISSION_READ ]); $cache->put('bar/asd/outside.txt', [ 'storage_mtime' => $baseTime, @@ -879,7 +881,8 @@ class FolderTest extends NodeTest { 'storage_mtime' => $baseTime - 600, 'mtime' => $baseTime - 600, 'mimetype' => 'text/plain', - 'size' => 3 + 'size' => 3, + 'permissions' => \OCP\Constants::PERMISSION_ALL ]); $node = new \OC\Files\Node\Folder($root, $view, $folderPath, $folderInfo); @@ -922,21 +925,24 @@ class FolderTest extends NodeTest { 'storage_mtime' => $baseTime, 'mtime' => $baseTime, 'mimetype' => \OCP\Files\FileInfo::MIMETYPE_FOLDER, - 'size' => 3 + 'size' => 3, + 'permissions' => 0 ]); $id2 = $cache->put('bar/foo/folder/bar.txt', [ 'storage_mtime' => $baseTime, 'mtime' => $baseTime, 'mimetype' => 'text/plain', 'size' => 3, - 'parent' => $id1 + 'parent' => $id1, + 'permissions' => \OCP\Constants::PERMISSION_ALL ]); $id3 = $cache->put('bar/foo/folder/asd.txt', [ 'storage_mtime' => $baseTime - 100, 'mtime' => $baseTime - 100, 'mimetype' => 'text/plain', 'size' => 3, - 'parent' => $id1 + 'parent' => $id1, + 'permissions' => \OCP\Constants::PERMISSION_ALL ]); $node = new \OC\Files\Node\Folder($root, $view, $folderPath, $folderInfo); @@ -985,7 +991,8 @@ class FolderTest extends NodeTest { 'storage_mtime' => $baseTime, 'mtime' => $baseTime, 'mimetype' => 'text/plain', - 'size' => 3 + 'size' => 3, + 'permissions' => \OCP\Constants::PERMISSION_ALL ]); $cache->put('outside.txt', [ 'storage_mtime' => $baseTime - 100, From e7920203bae74dfa1b52ead4f989f4905d504a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 22 Jul 2019 17:22:05 +0200 Subject: [PATCH 2/2] Add additional check for read permissions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/Files/Node/Folder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 7f908a757a..19f0404877 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -447,7 +447,8 @@ class Folder extends Node implements \OCP\Files\Folder { return false; } $relative = $this->getRelativePath($node->getPath()); - return $relative !== null && $relative !== '/'; + return $relative !== null && $relative !== '/' + && ($cacheEntry->getPermissions() & \OCP\Constants::PERMISSION_READ) === \OCP\Constants::PERMISSION_READ; })); }