diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index b4376eb2d985c..75e203d5fd959 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -199,12 +199,8 @@ public function searchInCaches(ISearchQuery $searchQuery, array $caches): array */ public function getCachesAndMountPointsForSearch(IRootFolder $root, string $path, bool $limitToHome = false): array { $rootLength = strlen($path); - $storage = null; - if (method_exists($root, 'getMount')) { - /** @var IMountPoint $mount */ - $mount = $root->getMount($path); - $storage = $mount->getStorage(); - } + $mount = $root->getMount($path); + $storage = $mount->getStorage(); if ($storage === null) { return []; } @@ -221,8 +217,7 @@ public function getCachesAndMountPointsForSearch(IRootFolder $root, string $path /** @var IMountPoint[] $mountByMountPoint */ $mountByMountPoint = ['' => $mount]; - if (!$limitToHome && method_exists($root, 'getMountsIn')) { - /** @var IMountPoint[] $mounts */ + if (!$limitToHome) { $mounts = $root->getMountsIn($path); foreach ($mounts as $mount) { $storage = $mount->getStorage(); diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 9714a0aea00d4..41bac26248bd8 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -330,12 +330,8 @@ protected function getAppDataDirectoryName(): string { * @return array */ protected function getByIdInRootMount(int $id): array { - $storage = null; - if (\method_exists($this->root, 'getMount')) { - /** @var IMountPoint $mount */ - $mount = $this->root->getMount(''); - $storage = $mount->getStorage(); - } + $mount = $this->root->getMount(''); + $storage = $mount->getStorage(); $cacheEntry = $storage?->getCache($this->path)->get($id); if (!$cacheEntry) { return []; diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index c843baabade00..8ea55dee1cf7e 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -29,6 +29,7 @@ use OC\Files\Utils\PathHelper; use OCP\Files\Folder; use OCP\Constants; +use OCP\Files\Mount\IMountPoint; /** * Class LazyFolder @@ -111,14 +112,14 @@ public function mount($storage, $mountPoint, $arguments = []) { /** * @inheritDoc */ - public function getMount($mountPoint) { + public function getMount(string $mountPoint): IMountPoint { return $this->__call(__FUNCTION__, func_get_args()); } /** * @inheritDoc */ - public function getMountsIn($mountPoint) { + public function getMountsIn(string $mountPoint): array { return $this->__call(__FUNCTION__, func_get_args()); } diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 0ed1bcab2aedf..7bd88981ff2f3 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -154,11 +154,7 @@ public function mount($storage, $mountPoint, $arguments = []) { $this->mountManager->addMount($mount); } - /** - * @param string $mountPoint - * @return \OC\Files\Mount\MountPoint - */ - public function getMount($mountPoint) { + public function getMount(string $mountPoint): IMountPoint { return $this->mountManager->find($mountPoint); } @@ -166,7 +162,7 @@ public function getMount($mountPoint) { * @param string $mountPoint * @return \OC\Files\Mount\MountPoint[] */ - public function getMountsIn($mountPoint) { + public function getMountsIn(string $mountPoint): array { return $this->mountManager->findIn($mountPoint); } diff --git a/lib/public/Files/IRootFolder.php b/lib/public/Files/IRootFolder.php index 452c0fd31573b..1fee0b3595e33 100644 --- a/lib/public/Files/IRootFolder.php +++ b/lib/public/Files/IRootFolder.php @@ -26,6 +26,7 @@ use OC\Hooks\Emitter; use OC\User\NoUserException; +use OCP\Files\Mount\IMountPoint; /** * Interface IRootFolder @@ -55,4 +56,16 @@ public function getUserFolder($userId); * @since 24.0.0 */ public function getByIdInPath(int $id, string $path); + + /** + * @return IMountPoint[] + * + * @since 28.0.0 + */ + public function getMountsIn(string $mountPoint): array; + + /** + * @since 28.0.0 + */ + public function getMount(string $mountPoint): IMountPoint; }