summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Cache
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-05-05 21:28:09 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2023-05-16 12:47:09 +0200
commitf2b5a079db5530cf48be137e5a52a984e27ab3ad (patch)
tree7aba77e4d5dddf304350b37c4e58c55b6a3f14bd /lib/private/Files/Cache
parentf50ce8b3bd3e119167f48972f5e5a55686145d72 (diff)
downloadnextcloud-server-f2b5a079db5530cf48be137e5a52a984e27ab3ad.tar.gz
nextcloud-server-f2b5a079db5530cf48be137e5a52a984e27ab3ad.zip
refactor: remove SystemTag logic from Folder into QuerySearchHelper
- adds OC\SystemTag\SystemTagsInFilesDetector where the search logic is moved to Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Files/Cache')
-rw-r--r--lib/private/Files/Cache/QuerySearchHelper.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php
index af198e9c832..f540f2dcb65 100644
--- a/lib/private/Files/Cache/QuerySearchHelper.php
+++ b/lib/private/Files/Cache/QuerySearchHelper.php
@@ -25,13 +25,18 @@
*/
namespace OC\Files\Cache;
+use OC\Files\Cache\Wrapper\CacheJail;
+use OC\Files\Node\Root;
use OC\Files\Search\QueryOptimizer\QueryOptimizer;
use OC\Files\Search\SearchBinaryOperator;
use OC\SystemConfig;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
+use OCP\Files\Folder;
use OCP\Files\IMimeTypeLoader;
+use OCP\Files\IRootFolder;
+use OCP\Files\Mount\IMountPoint;
use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchQuery;
use OCP\IDBConnection;
@@ -190,4 +195,38 @@ class QuerySearchHelper {
}
return $results;
}
+
+ /**
+ * @return array{array<string, ICache>, array<string, IMountPoint>}
+ */
+ public function getCachesAndMountPointsForSearch(Root $root, string $path, bool $limitToHome = false): array {
+ $rootLength = strlen($path);
+ $mount = $root->getMount($path);
+ $storage = $mount->getStorage();
+ $internalPath = $mount->getInternalPath($path);
+
+ if ($internalPath !== '') {
+ // a temporary CacheJail is used to handle filtering down the results to within this folder
+ $caches = ['' => new CacheJail($storage->getCache(''), $internalPath)];
+ } else {
+ $caches = ['' => $storage->getCache('')];
+ }
+ $mountByMountPoint = ['' => $mount];
+
+ if (!$limitToHome) {
+ /** @var IMountPoint[] $mounts */
+ $mounts = $root->getMountsIn($path);
+ foreach ($mounts as $mount) {
+ $storage = $mount->getStorage();
+ if ($storage) {
+ $relativeMountPoint = ltrim(substr($mount->getMountPoint(), $rootLength), '/');
+ $caches[$relativeMountPoint] = $storage->getCache('');
+ $mountByMountPoint[$relativeMountPoint] = $mount;
+ }
+ }
+ }
+
+ return [$caches, $mountByMountPoint];
+ }
+
}