Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/files_sharing/lib/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,18 @@ public function clear() {
}

public function getQueryFilterForStorage(): ISearchOperator {
$storageFilter = \OC\Files\Cache\Cache::getQueryFilterForStorage();
icewind1991 marked this conversation as resolved.
Show resolved Hide resolved

// 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()),
]
);
Expand Down
8 changes: 6 additions & 2 deletions lib/private/Files/Cache/Wrapper/CacheJail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -319,7 +323,7 @@ public function getQueryFilterForStorage(): ISearchOperator {
]
);
} else {
return $this->getCache()->getQueryFilterForStorage();
return $filter;
}
}

Expand Down