]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Fix other uses of removed Storage interface
authorCôme Chilliet <come.chilliet@nextcloud.com>
Sun, 15 Sep 2024 13:38:25 +0000 (15:38 +0200)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 16 Sep 2024 16:11:36 +0000 (18:11 +0200)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/files_sharing/lib/SharedStorage.php
apps/files_sharing/tests/SharedStorageTest.php
lib/private/Files/Storage/Storage.php
lib/private/Files/Storage/StorageFactory.php
lib/public/Files/Storage/IStorage.php
tests/lib/Files/Storage/Storage.php
tests/lib/Files/Storage/StorageFactoryTest.php

index 00f757d4734403e894ee2a6d0de0ee8a20aa8292..62f5880294cf17af548a83e83157032177419056 100644 (file)
@@ -27,6 +27,7 @@ use OCP\Files\IHomeStorage;
 use OCP\Files\IRootFolder;
 use OCP\Files\NotFoundException;
 use OCP\Files\Storage\IDisableEncryptionStorage;
+use OCP\Files\Storage\ILockingStorage;
 use OCP\Files\Storage\ISharedStorage;
 use OCP\Files\Storage\IStorage;
 use OCP\Lock\ILockingProvider;
@@ -494,7 +495,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
         * @throws \OCP\Lock\LockedException
         */
        public function acquireLock($path, $type, ILockingProvider $provider) {
-               /** @var \OCP\Files\Storage $targetStorage */
+               /** @var ILockingStorage $targetStorage */
                [$targetStorage, $targetInternalPath] = $this->resolvePath($path);
                $targetStorage->acquireLock($targetInternalPath, $type, $provider);
                // lock the parent folders of the owner when locking the share as recipient
@@ -510,7 +511,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
         * @param \OCP\Lock\ILockingProvider $provider
         */
        public function releaseLock($path, $type, ILockingProvider $provider) {
-               /** @var \OCP\Files\Storage $targetStorage */
+               /** @var ILockingStorage $targetStorage */
                [$targetStorage, $targetInternalPath] = $this->resolvePath($path);
                $targetStorage->releaseLock($targetInternalPath, $type, $provider);
                // unlock the parent folders of the owner when unlocking the share as recipient
@@ -526,7 +527,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
         * @param \OCP\Lock\ILockingProvider $provider
         */
        public function changeLock($path, $type, ILockingProvider $provider) {
-               /** @var \OCP\Files\Storage $targetStorage */
+               /** @var ILockingStorage $targetStorage */
                [$targetStorage, $targetInternalPath] = $this->resolvePath($path);
                $targetStorage->changeLock($targetInternalPath, $type, $provider);
        }
index 5f907ad8de37a4ea2c7eae244818e5ee6af98114..49ff97c053a92a0b36f30d5ede0faca4ce3bf312 100644 (file)
@@ -416,9 +416,6 @@ class SharedStorageTest extends TestCase {
                $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
                $this->assertTrue($view->file_exists($this->folder));
 
-               /**
-                * @var \OCP\Files\Storage $sharedStorage
-                */
                [$sharedStorage,] = $view->resolvePath($this->folder);
                $this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage'));
 
@@ -449,9 +446,6 @@ class SharedStorageTest extends TestCase {
                $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
                $this->assertTrue($view->file_exists($this->folder));
 
-               /**
-                * @var \OCP\Files\Storage $sharedStorage
-                */
                [$sharedStorage,] = $view->resolvePath($this->folder);
                $this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage'));
 
index 44b1a52cfc0b36cfccee9add971f8e44529bc1f2..8f37daaf613268e2d3df37414cdd95c6a9babdf7 100644 (file)
@@ -5,68 +5,17 @@
  * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  * SPDX-License-Identifier: AGPL-3.0-only
  */
+
 namespace OC\Files\Storage;
 
-use OCP\Lock\ILockingProvider;
+use OCP\Files\Storage\IStorage;
 
 /**
  * Provide a common interface to all different storage options
  *
  * All paths passed to the storage are relative to the storage and should NOT have a leading slash.
  */
-interface Storage extends \OCP\Files\Storage {
-       /**
-        * get a cache instance for the storage
-        *
-        * @param string $path
-        * @param \OC\Files\Storage\Storage|null (optional) the storage to pass to the cache
-        * @return \OC\Files\Cache\Cache
-        */
-       public function getCache($path = '', $storage = null);
-
-       /**
-        * get a scanner instance for the storage
-        *
-        * @param string $path
-        * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
-        * @return \OC\Files\Cache\Scanner
-        */
-       public function getScanner($path = '', $storage = null);
-
-
-       /**
-        * get the user id of the owner of a file or folder
-        *
-        * @param string $path
-        * @return string
-        */
-       public function getOwner($path);
-
-       /**
-        * get a watcher instance for the cache
-        *
-        * @param string $path
-        * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
-        * @return \OC\Files\Cache\Watcher
-        */
-       public function getWatcher($path = '', $storage = null);
-
-       /**
-        * get a propagator instance for the cache
-        *
-        * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
-        * @return \OC\Files\Cache\Propagator
-        */
-       public function getPropagator($storage = null);
-
-       /**
-        * get a updater instance for the cache
-        *
-        * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
-        * @return \OC\Files\Cache\Updater
-        */
-       public function getUpdater($storage = null);
-
+interface Storage extends IStorage {
        /**
         * @return \OC\Files\Cache\Storage
         */
@@ -78,30 +27,6 @@ interface Storage extends \OCP\Files\Storage {
         */
        public function getMetaData($path);
 
-       /**
-        * @param string $path The path of the file to acquire the lock for
-        * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
-        * @param \OCP\Lock\ILockingProvider $provider
-        * @throws \OCP\Lock\LockedException
-        */
-       public function acquireLock($path, $type, ILockingProvider $provider);
-
-       /**
-        * @param string $path The path of the file to release the lock for
-        * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
-        * @param \OCP\Lock\ILockingProvider $provider
-        * @throws \OCP\Lock\LockedException
-        */
-       public function releaseLock($path, $type, ILockingProvider $provider);
-
-       /**
-        * @param string $path The path of the file to change the lock for
-        * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
-        * @param \OCP\Lock\ILockingProvider $provider
-        * @throws \OCP\Lock\LockedException
-        */
-       public function changeLock($path, $type, ILockingProvider $provider);
-
        /**
         * Get the contents of a directory with metadata
         *
index 612592e2d3ae02a21226e225d124455b1dddc439..590425f5b641bb37f3e9cff8418265d23c25f9f1 100644 (file)
@@ -8,6 +8,7 @@
 namespace OC\Files\Storage;
 
 use OCP\Files\Mount\IMountPoint;
+use OCP\Files\Storage\IStorage;
 use OCP\Files\Storage\IStorageFactory;
 
 class StorageFactory implements IStorageFactory {
@@ -56,19 +57,17 @@ class StorageFactory implements IStorageFactory {
        /**
         * Create an instance of a storage and apply the registered storage wrappers
         *
-        * @param \OCP\Files\Mount\IMountPoint $mountPoint
         * @param string $class
         * @param array $arguments
-        * @return \OCP\Files\Storage
+        * @return IStorage
         */
        public function getInstance(IMountPoint $mountPoint, $class, $arguments) {
                return $this->wrap($mountPoint, new $class($arguments));
        }
 
        /**
-        * @param \OCP\Files\Mount\IMountPoint $mountPoint
-        * @param \OCP\Files\Storage $storage
-        * @return \OCP\Files\Storage
+        * @param IStorage $storage
+        * @return IStorage
         */
        public function wrap(IMountPoint $mountPoint, $storage) {
                $wrappers = array_values($this->storageWrappers);
@@ -81,7 +80,7 @@ class StorageFactory implements IStorageFactory {
                }, $wrappers);
                foreach ($wrappers as $wrapper) {
                        $storage = $wrapper($mountPoint->getMountPoint(), $storage, $mountPoint);
-                       if (!($storage instanceof \OCP\Files\Storage)) {
+                       if (!($storage instanceof IStorage)) {
                                throw new \Exception('Invalid result from storage wrapper');
                        }
                }
index e18d6768346800af61c9a4e1663c1f008fa6e228..907670052392faf6b384708715c70af7ce4e3f1d 100644 (file)
@@ -279,6 +279,15 @@ interface IStorage {
         */
        public function free_space($path);
 
+       /**
+        * search for occurrences of $query in file names
+        *
+        * @param string $query
+        * @return array|bool
+        * @since 6.0.0
+        */
+       public function search($query);
+
        /**
         * see https://www.php.net/manual/en/function.touch.php
         * If the backend does not support the operation, false should be returned
@@ -404,6 +413,12 @@ interface IStorage {
         */
        public function setAvailability($isAvailable);
 
+       /**
+        * @since 12.0.0
+        * @return mixed
+        */
+       public function needsPartFile();
+
        /**
         * @param string $path path for which to retrieve the owner
         * @since 9.0.0
index 5b0bbf2f95bf1ca4a470225d04581f39567203dc..36d709658484feaa6eaae3be37d798c31b5511d5 100644 (file)
@@ -8,6 +8,7 @@
 namespace Test\Files\Storage;
 
 use OC\Files\Cache\Watcher;
+use OCP\Files\Storage\IStorage;
 use OCP\Files\Storage\IWriteStreamStorage;
 
 abstract class Storage extends \Test\TestCase {
@@ -572,7 +573,7 @@ abstract class Storage extends \Test\TestCase {
        }
 
        public function testInstanceOfStorage(): void {
-               $this->assertTrue($this->instance->instanceOfStorage('\OCP\Files\Storage'));
+               $this->assertTrue($this->instance->instanceOfStorage(IStorage::class));
                $this->assertTrue($this->instance->instanceOfStorage(get_class($this->instance)));
                $this->assertFalse($this->instance->instanceOfStorage('\OC'));
        }
index 66f2a2af9a6e778fe5b147a0e5c2f5b568f0670a..d1e8d927dc9304f48844bcdee7c84505559595ce 100644 (file)
@@ -10,7 +10,7 @@ namespace Test\Files\Storage;
 use OC\Files\Mount\MountPoint;
 use OC\Files\Storage\Wrapper\Wrapper;
 use OCP\Files\Mount\IMountPoint;
-use OCP\Files\Storage as IStorage;
+use OCP\Files\Storage\IStorage;
 use Test\TestCase;
 
 class DummyWrapper extends Wrapper {