summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-06-16 09:07:40 +0200
committerGitHub <noreply@github.com>2021-06-16 09:07:40 +0200
commit437d938e8cf0b37fb3fc7893251f1470b9233fa0 (patch)
tree8f404cbdf19e14601a08313193c62e620c8485b3 /apps
parent4c60ff127554020ceeac1ca0e7403dbad4295018 (diff)
parent362cb2a11f7a95762ecfc7662768442bca233018 (diff)
downloadnextcloud-server-437d938e8cf0b37fb3fc7893251f1470b9233fa0.tar.gz
nextcloud-server-437d938e8cf0b37fb3fc7893251f1470b9233fa0.zip
Merge pull request #26874 from nextcloud/single-query-search
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Cache.php27
-rw-r--r--apps/files_trashbin/lib/Trashbin.php5
2 files changed, 18 insertions, 14 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php
index 29224c5fb6b..25e92d23962 100644
--- a/apps/files_sharing/lib/Cache.php
+++ b/apps/files_sharing/lib/Cache.php
@@ -30,8 +30,13 @@ namespace OCA\Files_Sharing;
use OC\Files\Cache\FailedCache;
use OC\Files\Cache\Wrapper\CacheJail;
+use OC\Files\Search\SearchBinaryOperator;
+use OC\Files\Search\SearchComparison;
use OC\Files\Storage\Wrapper\Jail;
use OCP\Files\Cache\ICacheEntry;
+use OCP\Files\Search\ISearchBinaryOperator;
+use OCP\Files\Search\ISearchComparison;
+use OCP\Files\Search\ISearchOperator;
use OCP\Files\StorageNotAvailableException;
/**
@@ -181,19 +186,19 @@ class Cache extends CacheJail {
// Not a valid action for Shared Cache
}
- public function search($pattern) {
- // Do the normal search on the whole storage for non files
+ public function getQueryFilterForStorage(): ISearchOperator {
+ // Do the normal jail behavior for non files
if ($this->storage->getItemType() !== 'file') {
- return parent::search($pattern);
+ return parent::getQueryFilterForStorage();
}
- $regex = '/' . str_replace('%', '.*', $pattern) . '/i';
-
- $data = $this->get('');
- if (preg_match($regex, $data->getName()) === 1) {
- return [$data];
- }
-
- return [];
+ // for single file shares we don't need to do the LIKE
+ return new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_AND,
+ [
+ \OC\Files\Cache\Cache::getQueryFilterForStorage(),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', $this->getGetUnjailedRoot()),
+ ]
+ );
}
}
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index 1cef0a6ed0a..0e16c56ed8d 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -988,8 +988,7 @@ class Trashbin {
$query = new CacheQueryBuilder(
\OC::$server->getDatabaseConnection(),
\OC::$server->getSystemConfig(),
- \OC::$server->getLogger(),
- $cache
+ \OC::$server->getLogger()
);
$normalizedParentPath = ltrim(Filesystem::normalizePath(dirname('files_trashbin/versions/'. $filename)), '/');
$parentId = $cache->getId($normalizedParentPath);
@@ -998,7 +997,7 @@ class Trashbin {
}
$query->selectFileCache()
- ->whereStorageId()
+ ->whereStorageId($cache->getNumericStorageId())
->andWhere($query->expr()->eq('parent', $query->createNamedParameter($parentId)))
->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern)));