3333
3434use OC \Files \Cache \QuerySearchHelper ;
3535use OC \Files \Search \SearchBinaryOperator ;
36- use OC \Files \Cache \Wrapper \CacheJail ;
3736use OC \Files \Search \SearchComparison ;
3837use OC \Files \Search \SearchOrder ;
3938use OC \Files \Search \SearchQuery ;
@@ -215,37 +214,6 @@ private function queryFromOperator(ISearchOperator $operator, string $uid = null
215214 return new SearchQuery ($ operator , $ limit , $ offset , [], $ user );
216215 }
217216
218- /**
219- * @psalm-return list{0: array<string, \OCP\Files\Cache\ICache>, 1: array<string, \OCP\Files\Mount\IMountPoint>}
220- */
221- protected function getCachesAndMountpointsForSearch (bool $ limitToHome = false ): array {
222- $ rootLength = strlen ($ this ->path );
223- $ mount = $ this ->root ->getMount ($ this ->path );
224- $ storage = $ mount ->getStorage ();
225- $ internalPath = $ mount ->getInternalPath ($ this ->path );
226- if ($ internalPath !== '' ) {
227- // a temporary CacheJail is used to handle filtering down the results to within this folder
228- $ caches = ['' => new CacheJail ($ storage ->getCache ('' ), $ internalPath )];
229- } else {
230- $ caches = ['' => $ storage ->getCache ('' )];
231- }
232- $ mountByMountPoint = ['' => $ mount ];
233-
234- if (!$ limitToHome ) {
235- $ mounts = $ this ->root ->getMountsIn ($ this ->path );
236- foreach ($ mounts as $ mount ) {
237- $ storage = $ mount ->getStorage ();
238- if ($ storage ) {
239- $ relativeMountPoint = ltrim (substr ($ mount ->getMountPoint (), $ rootLength ), '/ ' );
240- $ caches [$ relativeMountPoint ] = $ storage ->getCache ('' );
241- $ mountByMountPoint [$ relativeMountPoint ] = $ mount ;
242- }
243- }
244- }
245-
246- return [$ caches , $ mountByMountPoint ];
247- }
248-
249217 /**
250218 * search for files with the name matching $query
251219 *
@@ -265,10 +233,9 @@ public function search($query) {
265233 throw new \InvalidArgumentException ('searching by owner is only allowed in the users home folder ' );
266234 }
267235
268- [$ caches , $ mountByMountPoint ] = $ this ->getCachesAndMountpointsForSearch ($ limitToHome );
269-
270236 /** @var QuerySearchHelper $searchHelper */
271237 $ searchHelper = \OC ::$ server ->get (QuerySearchHelper::class);
238+ [$ caches , $ mountByMountPoint ] = $ searchHelper ->getCachesAndMountPointsForSearch ($ this ->root , $ this ->path , $ limitToHome );
272239 $ resultsPerCache = $ searchHelper ->searchInCaches ($ query , $ caches );
273240
274241 // loop through all results per-cache, constructing the FileInfo object from the CacheEntry and merge them all
@@ -337,24 +304,6 @@ public function searchByTag($tag, $userId) {
337304 return $ this ->search ($ query );
338305 }
339306
340- /**
341- *
342- * @return array<array-key, array{id: int, name: string, visibility: int, editable: int, ref_file_id: int, number_files: int}>
343- */
344- public function getSystemTags (string $ mediaType , int $ limit = 0 , int $ offset = 0 ): array {
345- // Currently query has to have exactly one search condition. If no media type is provided,
346- // we fall back to the presence of a systemtag.
347- if (empty ($ mediaType )) {
348- $ query = $ this ->queryFromOperator (new SearchComparison (ISearchComparison::COMPARE_LIKE , 'systemtag ' , '% ' ), null , $ limit , $ offset );
349- } else {
350- $ query = $ this ->queryFromOperator (new SearchComparison (ISearchComparison::COMPARE_LIKE , 'mimetype ' , $ mediaType . '/% ' ), null , $ limit , $ offset );
351- }
352- [$ caches , ] = $ this ->getCachesAndMountpointsForSearch ();
353- /** @var QuerySearchHelper $searchHelper */
354- $ searchHelper = \OCP \Server::get (QuerySearchHelper::class);
355- return $ searchHelper ->findUsedTagsInCaches ($ query , $ caches );
356- }
357-
358307 /**
359308 * @param int $id
360309 * @return \OC\Files\Node\Node[]
0 commit comments