diff options
author | Vincent Petry <vincent@nextcloud.com> | 2021-03-15 17:45:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-15 17:45:30 +0100 |
commit | e559afb8d409f75fdf9a216428d858d08aa1ee03 (patch) | |
tree | afea41e1f4cf5f9f25070e819ef9637267c63ec0 /apps | |
parent | f512705f8f3ba7ff676b139bbfc00dcf6d277bd1 (diff) | |
parent | 6ecf33bfe7ef719cd979de5b29fc1da02e255632 (diff) | |
download | nextcloud-server-e559afb8d409f75fdf9a216428d858d08aa1ee03.tar.gz nextcloud-server-e559afb8d409f75fdf9a216428d858d08aa1ee03.zip |
Merge pull request #25136 from nextcloud/cachejail-search-filter
do cachejail search filtering in sql
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/Cache.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/tests/CacheTest.php | 36 |
2 files changed, 40 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index c3f31ac3e4f..3a6ade5a2ac 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -89,6 +89,10 @@ class Cache extends CacheJail { return $this->root; } + protected function getGetUnjailedRoot() { + return $this->sourceRootInfo->getPath(); + } + public function getCache() { if (is_null($this->cache)) { $sourceStorage = $this->storage->getSourceStorage(); diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php index 5136f0972ea..a30409a0e37 100644 --- a/apps/files_sharing/tests/CacheTest.php +++ b/apps/files_sharing/tests/CacheTest.php @@ -517,4 +517,40 @@ class CacheTest extends TestCase { $this->assertTrue($sourceStorage->getCache()->inCache('jail/sub/bar.txt')); } + + public function testSearchShareJailedStorage() { + $sourceStorage = new Temporary(); + $sourceStorage->mkdir('jail'); + $sourceStorage->mkdir('jail/sub'); + $sourceStorage->file_put_contents('jail/sub/foo.txt', 'foo'); + $jailedSource = new Jail([ + 'storage' => $sourceStorage, + 'root' => 'jail' + ]); + $sourceStorage->getScanner()->scan(''); + $this->registerMount(self::TEST_FILES_SHARING_API_USER1, $jailedSource, '/' . self::TEST_FILES_SHARING_API_USER1 . '/files/foo'); + + self::loginHelper(self::TEST_FILES_SHARING_API_USER1); + + $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1); + $node = $rootFolder->get('foo/sub'); + $share = $this->shareManager->newShare(); + $share->setNode($node) + ->setShareType(IShare::TYPE_USER) + ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) + ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) + ->setPermissions(\OCP\Constants::PERMISSION_ALL); + $share = $this->shareManager->createShare($share); + $share->setStatus(IShare::STATUS_ACCEPTED); + $this->shareManager->updateShare($share); + \OC_Util::tearDownFS(); + + self::loginHelper(self::TEST_FILES_SHARING_API_USER2); + + /** @var SharedStorage $sharedStorage */ + list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/sub'); + + $results = $sharedStorage->getCache()->search("foo.txt"); + $this->assertCount(1, $results); + } } |