directly build the search filter for shared storage instead of setting up the source cache

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2022-08-17 11:58:57 +02:00
parent 312b719acf
commit b6f8b8da60
2 changed files with 10 additions and 4 deletions

View file

@ -183,16 +183,18 @@ class Cache extends CacheJail {
}
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()),
]
);

View file

@ -306,10 +306,14 @@ class CacheJail extends CacheWrapper {
}
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 @@ class CacheJail extends CacheWrapper {
]
);
} else {
return $this->getCache()->getQueryFilterForStorage();
return $filter;
}
}