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 /lib/private/Files/Cache/Wrapper/CacheWrapper.php | |
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 'lib/private/Files/Cache/Wrapper/CacheWrapper.php')
-rw-r--r-- | lib/private/Files/Cache/Wrapper/CacheWrapper.php | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php index 01fbdd3bf42..edda332af67 100644 --- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php +++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php @@ -30,6 +30,8 @@ namespace OC\Files\Cache\Wrapper; use OC\Files\Cache\Cache; +use OC\Files\Cache\QuerySearchHelper; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Cache\ICache; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Search\ISearchQuery; @@ -45,6 +47,14 @@ class CacheWrapper extends Cache { */ public function __construct($cache) { $this->cache = $cache; + $this->mimetypeLoader = \OC::$server->getMimeTypeLoader(); + $this->connection = \OC::$server->getDatabaseConnection(); + $this->querySearchHelper = new QuerySearchHelper( + $this->mimetypeLoader, + $this->connection, + \OC::$server->getSystemConfig(), + \OC::$server->getLogger() + ); } protected function getCache() { @@ -215,31 +225,8 @@ class CacheWrapper extends Cache { return $this->getCache()->getStatus($file); } - /** - * search for files matching $pattern - * - * @param string $pattern - * @return ICacheEntry[] an array of file data - */ - public function search($pattern) { - $results = $this->getCache()->search($pattern); - return array_map([$this, 'formatCacheEntry'], $results); - } - - /** - * search for files by mimetype - * - * @param string $mimetype - * @return ICacheEntry[] - */ - public function searchByMime($mimetype) { - $results = $this->getCache()->searchByMime($mimetype); - return array_map([$this, 'formatCacheEntry'], $results); - } - - public function searchQuery(ISearchQuery $query) { - $results = $this->getCache()->searchQuery($query); - return array_map([$this, 'formatCacheEntry'], $results); + public function searchQuery(ISearchQuery $searchQuery) { + return $this->querySearchHelper->searchInCaches($searchQuery, [$this]); } /** @@ -321,4 +308,17 @@ class CacheWrapper extends Cache { public static function getById($id) { return parent::getById($id); } + + public function getQueryFilterForStorage(IQueryBuilder $builder) { + return $this->getCache()->getQueryFilterForStorage($builder); + } + + public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { + $rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry); + if ($rawEntry) { + return $this->formatCacheEntry(clone $rawEntry); + } + + return null; + } } |