diff options
author | Robin Appelman <robin@icewind.nl> | 2021-05-04 19:06:02 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2021-06-14 16:11:22 +0200 |
commit | e198dc1b200f3ade93498e0ea7b468c87d46748a (patch) | |
tree | 235c30d6035bec46bef5ee2f2b134333dfb65409 /apps/files_sharing | |
parent | dfbac05f7ba00c78ac15df61a425317a890b08d1 (diff) | |
download | nextcloud-server-e198dc1b200f3ade93498e0ea7b468c87d46748a.tar.gz nextcloud-server-e198dc1b200f3ade93498e0ea7b468c87d46748a.zip |
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')
-rw-r--r-- | apps/files_sharing/lib/Cache.php | 22 |
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()))), + ) + ); } } |