From f6ac874dbf7d4e5cb2255f25464df214bb956ffb Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 8 Jun 2023 23:32:16 +0200 Subject: chore: ugly type juggling Signed-off-by: Arthur Schiwon --- lib/private/Files/Cache/QuerySearchHelper.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/private/Files/Cache/QuerySearchHelper.php') diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index 52663213b16..b4376eb2d98 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -195,23 +195,33 @@ class QuerySearchHelper { } /** - * @return array{array, array} + * @return list{0?: array, 1?: array} */ public function getCachesAndMountPointsForSearch(IRootFolder $root, string $path, bool $limitToHome = false): array { $rootLength = strlen($path); - $mount = $root->getMount($path); - $storage = $mount->getStorage(); + $storage = null; + if (method_exists($root, 'getMount')) { + /** @var IMountPoint $mount */ + $mount = $root->getMount($path); + $storage = $mount->getStorage(); + } + if ($storage === null) { + return []; + } $internalPath = $mount->getInternalPath($path); if ($internalPath !== '') { // a temporary CacheJail is used to handle filtering down the results to within this folder + /** @var ICache[] $caches */ $caches = ['' => new CacheJail($storage->getCache(''), $internalPath)]; } else { + /** @var ICache[] $caches */ $caches = ['' => $storage->getCache('')]; } + /** @var IMountPoint[] $mountByMountPoint */ $mountByMountPoint = ['' => $mount]; - if (!$limitToHome) { + if (!$limitToHome && method_exists($root, 'getMountsIn')) { /** @var IMountPoint[] $mounts */ $mounts = $root->getMountsIn($path); foreach ($mounts as $mount) { -- cgit v1.2.3