summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2021-03-16 16:59:29 +0100
committerGitHub <noreply@github.com>2021-03-16 16:59:29 +0100
commit120aefb79505b671ea99f85cc381e05765c3ca15 (patch)
tree13058255f25b800060c71edaf29158f8316aece0 /apps/files_sharing
parente09d59aa8184c7ea01e80d61eb2850642f97b53b (diff)
parente5ffb96c36f89113fcca8e0f5bdfdb98040186b6 (diff)
downloadnextcloud-server-120aefb79505b671ea99f85cc381e05765c3ca15.tar.gz
nextcloud-server-120aefb79505b671ea99f85cc381e05765c3ca15.zip
Merge pull request #26133 from nextcloud/backport/25136/stable21
[stable21] do cachejail search filtering in sql
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/Cache.php4
-rw-r--r--apps/files_sharing/tests/CacheTest.php36
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 b55fba78d42..ba9f347e291 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);
+ }
}