diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index 707b64b79d737..7433c15ad8594 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -183,16 +183,18 @@ public function clear() { } public function getQueryFilterForStorage(): ISearchOperator { + $storageFilter = \OC\Files\Cache\Cache::getQueryFilterForStorage(); + // Do the normal jail behavior for non files if ($this->storage->getItemType() !== 'file') { - return parent::getQueryFilterForStorage(); + return $this->addJailFilterQuery($storageFilter); } // for single file shares we don't need to do the LIKE return new SearchBinaryOperator( ISearchBinaryOperator::OPERATOR_AND, [ - \OC\Files\Cache\Cache::getQueryFilterForStorage(), + $storageFilter, new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', $this->getGetUnjailedRoot()), ] ); diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index 834c9fd3d727d..996f0c026030d 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -306,10 +306,14 @@ public function moveFromCache(\OCP\Files\Cache\ICache $sourceCache, $sourcePath, } public function getQueryFilterForStorage(): ISearchOperator { + return $this->addJailFilterQuery($this->getCache()->getQueryFilterForStorage()); + } + + protected function addJailFilterQuery(ISearchOperator $filter): ISearchOperator { if ($this->getGetUnjailedRoot() !== '' && $this->getGetUnjailedRoot() !== '/') { return new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [ - $this->getCache()->getQueryFilterForStorage(), + $filter, new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [ new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', $this->getGetUnjailedRoot()), @@ -319,7 +323,7 @@ public function getQueryFilterForStorage(): ISearchOperator { ] ); } else { - return $this->getCache()->getQueryFilterForStorage(); + return $filter; } }