]> source.dussan.org Git - nextcloud-server.git/commitdiff
refactor: declare getMount() and getMountsIn() at IRootFolder
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 15 Jun 2023 21:21:56 +0000 (23:21 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 21 Jun 2023 14:53:20 +0000 (16:53 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
lib/private/Files/Cache/QuerySearchHelper.php
lib/private/Files/Node/Folder.php
lib/private/Files/Node/LazyFolder.php
lib/private/Files/Node/Root.php
lib/public/Files/IRootFolder.php

index b4376eb2d985cffb045a760aaea6441c6bae1190..75e203d5fd9598b6f8414a3beb40b4ff299766f4 100644 (file)
@@ -199,12 +199,8 @@ class QuerySearchHelper {
         */
        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 @@ class QuerySearchHelper {
                /** @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();
index 9714a0aea00d4f6ad39c445d84c9c2a03ff0e002..41bac26248bd8408b19276f26e002bf95fb19d7e 100644 (file)
@@ -330,12 +330,8 @@ class Folder extends Node implements \OCP\Files\Folder {
         * @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 [];
index c843baabade003246db0b4374519c0895f9d171d..9f9528f69bd54f8a474b7db25e9c212248fa7221 100644 (file)
@@ -29,6 +29,7 @@ namespace OC\Files\Node;
 use OC\Files\Utils\PathHelper;
 use OCP\Files\Folder;
 use OCP\Constants;
+use OCP\Files\Mount\IMountPoint;
 
 /**
  * Class LazyFolder
@@ -111,14 +112,14 @@ class LazyFolder implements Folder {
        /**
         * @inheritDoc
         */
-       public function getMount($mountPoint) {
+       public function getMount(string $mountPoint): IMountPoint {
                return $this->__call(__FUNCTION__, func_get_args());
        }
 
        /**
-        * @inheritDoc
+        * @return IMountPoint[]
         */
-       public function getMountsIn($mountPoint) {
+       public function getMountsIn(string $mountPoint): array {
                return $this->__call(__FUNCTION__, func_get_args());
        }
 
index 0ed1bcab2aedfa75d5f6dbd3819037ec90e716cc..7bd88981ff2f37fb1db7f193152fa7c522084db5 100644 (file)
@@ -154,11 +154,7 @@ class Root extends Folder implements IRootFolder {
                $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 @@ class Root extends Folder implements IRootFolder {
         * @param string $mountPoint
         * @return \OC\Files\Mount\MountPoint[]
         */
-       public function getMountsIn($mountPoint) {
+       public function getMountsIn(string $mountPoint): array {
                return $this->mountManager->findIn($mountPoint);
        }
 
index 452c0fd31573bab20a08bf723932e25c02310e9a..1fee0b3595e3346c78cb716ac51d5a923e5f0c9a 100644 (file)
@@ -26,6 +26,7 @@ namespace OCP\Files;
 
 use OC\Hooks\Emitter;
 use OC\User\NoUserException;
+use OCP\Files\Mount\IMountPoint;
 
 /**
  * Interface IRootFolder
@@ -55,4 +56,16 @@ interface IRootFolder extends Folder, Emitter {
         * @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;
 }