Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-05-04 20:06:02 +0300
committerRobin Appelman <robin@icewind.nl>2021-06-14 17:11:22 +0300
commite198dc1b200f3ade93498e0ea7b468c87d46748a (patch)
tree235c30d6035bec46bef5ee2f2b134333dfb65409 /apps/files_sharing/lib
parentdfbac05f7ba00c78ac15df61a425317a890b08d1 (diff)
rework search api to allow searching on multiple caches at once
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/Cache.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php
index 29224c5fb6b..b703a672a25 100644
--- a/apps/files_sharing/lib/Cache.php
+++ b/apps/files_sharing/lib/Cache.php
@@ -31,6 +31,7 @@ namespace OCA\Files_Sharing;
use OC\Files\Cache\FailedCache;
use OC\Files\Cache\Wrapper\CacheJail;
use OC\Files\Storage\Wrapper\Jail;
+use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\StorageNotAvailableException;
@@ -181,19 +182,18 @@ 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(IQueryBuilder $builder) {
+ // Do the normal jail behavior for non files
if ($this->storage->getItemType() !== 'file') {
- return parent::search($pattern);
+ return parent::getQueryFilterForStorage($builder);
}
- $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 $builder->expr()->andX(
+ parent::getQueryFilterForStorage($builder),
+ $builder->expr()->orX(
+ $builder->expr()->eq('path_hash', $builder->createNamedParameter(md5($this->getGetUnjailedRoot()))),
+ )
+ );
}
}