diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2024-09-16 20:50:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 20:50:38 +0200 |
commit | b9fb1db0f807fbbbfdbbf544a24d7cc3b396ec14 (patch) | |
tree | a48200e434ebd104fb94377e1a4807494ed2f9ae /lib | |
parent | ede0c26b78722f07ea4b672ff7c00f9723e0454e (diff) | |
parent | 03b969fb9597ae86564ad5f8a83d6fd64bd1d65a (diff) | |
download | nextcloud-server-b9fb1db0f807fbbbfdbbf544a24d7cc3b396ec14.tar.gz nextcloud-server-b9fb1db0f807fbbbfdbbf544a24d7cc3b396ec14.zip |
Merge pull request #48009 from nextcloud/fix/remove-references-to-deprected-storage-interface
fix: Remove OCP\Files\Storage interface deprecated since version 9
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/private/Files/Cache/Scanner.php | 13 | ||||
-rw-r--r-- | lib/private/Files/ObjectStore/ObjectStoreStorage.php | 1 | ||||
-rw-r--r-- | lib/private/Files/Storage/Common.php | 41 | ||||
-rw-r--r-- | lib/private/Files/Storage/Home.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Storage/Storage.php | 39 | ||||
-rw-r--r-- | lib/private/Files/Storage/StorageFactory.php | 11 | ||||
-rw-r--r-- | lib/private/Files/Storage/Temporary.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Encoding.php | 10 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Jail.php | 10 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Wrapper.php | 10 | ||||
-rw-r--r-- | lib/public/Files/Storage.php | 445 | ||||
-rw-r--r-- | lib/public/Files/Storage/IStorage.php | 9 | ||||
-rw-r--r-- | lib/public/Files/Storage/IStorageFactory.php | 4 |
15 files changed, 61 insertions, 540 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 5510143197a..78aca5fe883 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -421,7 +421,6 @@ return array( 'OCP\\Files\\SimpleFS\\ISimpleFolder' => $baseDir . '/lib/public/Files/SimpleFS/ISimpleFolder.php', 'OCP\\Files\\SimpleFS\\ISimpleRoot' => $baseDir . '/lib/public/Files/SimpleFS/ISimpleRoot.php', 'OCP\\Files\\SimpleFS\\InMemoryFile' => $baseDir . '/lib/public/Files/SimpleFS/InMemoryFile.php', - 'OCP\\Files\\Storage' => $baseDir . '/lib/public/Files/Storage.php', 'OCP\\Files\\StorageAuthException' => $baseDir . '/lib/public/Files/StorageAuthException.php', 'OCP\\Files\\StorageBadConfigException' => $baseDir . '/lib/public/Files/StorageBadConfigException.php', 'OCP\\Files\\StorageConnectionException' => $baseDir . '/lib/public/Files/StorageConnectionException.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 7b8584b5438..6a17bc4ff31 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -454,7 +454,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Files\\SimpleFS\\ISimpleFolder' => __DIR__ . '/../../..' . '/lib/public/Files/SimpleFS/ISimpleFolder.php', 'OCP\\Files\\SimpleFS\\ISimpleRoot' => __DIR__ . '/../../..' . '/lib/public/Files/SimpleFS/ISimpleRoot.php', 'OCP\\Files\\SimpleFS\\InMemoryFile' => __DIR__ . '/../../..' . '/lib/public/Files/SimpleFS/InMemoryFile.php', - 'OCP\\Files\\Storage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage.php', 'OCP\\Files\\StorageAuthException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageAuthException.php', 'OCP\\Files\\StorageBadConfigException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageBadConfigException.php', 'OCP\\Files\\StorageConnectionException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageConnectionException.php', diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index c85104ac4b9..6e1c86eed47 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -15,6 +15,7 @@ use OC\SystemConfig; use OCP\Files\Cache\IScanner; use OCP\Files\ForbiddenException; use OCP\Files\NotFoundException; +use OCP\Files\Storage\ILockingStorage; use OCP\Files\Storage\IReliableEtagStorage; use OCP\IDBConnection; use OCP\Lock\ILockingProvider; @@ -125,7 +126,7 @@ class Scanner extends BasicEmitter implements IScanner { if (!self::isPartialFile($file)) { // acquire a lock if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->acquireLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -134,7 +135,7 @@ class Scanner extends BasicEmitter implements IScanner { $data = $data ?? $this->getData($file); } catch (ForbiddenException $e) { if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -233,7 +234,7 @@ class Scanner extends BasicEmitter implements IScanner { } } catch (\Exception $e) { if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -242,7 +243,7 @@ class Scanner extends BasicEmitter implements IScanner { // release the acquired lock if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -319,7 +320,7 @@ class Scanner extends BasicEmitter implements IScanner { $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG; } if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->acquireLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } @@ -337,7 +338,7 @@ class Scanner extends BasicEmitter implements IScanner { } } finally { if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); $this->storage->releaseLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); } diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 228fc516677..663041ed92c 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -141,6 +141,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil if (!isset($this->scanner)) { $this->scanner = new ObjectStoreScanner($storage); } + /** @var \OC\Files\ObjectStore\ObjectStoreScanner */ return $this->scanner; } diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index cefba66683b..eb93ab89bc7 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -44,14 +44,14 @@ use Psr\Log\LoggerInterface; abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { use LocalTempFileTrait; - protected $cache; - protected $scanner; - protected $watcher; - protected $propagator; + protected ?Cache $cache = null; + protected ?Scanner $scanner = null; + protected ?Watcher $watcher = null; + protected ?Propagator $propagator = null; protected $storageCache; - protected $updater; + protected ?Updater $updater = null; - protected $mountOptions = []; + protected array $mountOptions = []; protected $owner = null; private ?bool $shouldLogLocks = null; @@ -232,10 +232,6 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { return hash_final($ctx, $raw); } - public function search($query) { - return $this->searchInDir($query); - } - public function getLocalFile($path) { return $this->getCachedFile($path); } @@ -310,13 +306,19 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { return $dependencies; } + /** + * @return Cache + */ public function getCache($path = '', $storage = null) { if (!$storage) { $storage = $this; } + /** @psalm-suppress NoInterfaceProperties The isset check is safe */ if (!isset($storage->cache)) { $storage->cache = new Cache($storage, $this->getCacheDependencies()); } + /** @psalm-suppress NullableReturnStatement False-positive, as the if above avoids this being null */ + /** @psalm-suppress NoInterfaceProperties Legacy */ return $storage->cache; } @@ -324,6 +326,9 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { if (!$storage) { $storage = $this; } + if (!$storage->instanceOfStorage(self::class)) { + throw new \InvalidArgumentException('Storage is not of the correct class'); + } if (!isset($storage->scanner)) { $storage->scanner = new Scanner($storage); } @@ -345,13 +350,16 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { /** * 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 + * @param \OC\Files\Storage\Storage $storage (optional) the storage to pass to the watcher + * @return Propagator */ public function getPropagator($storage = null) { if (!$storage) { $storage = $this; } + if (!$storage->instanceOfStorage(self::class)) { + throw new \InvalidArgumentException('Storage is not of the correct class'); + } if (!isset($storage->propagator)) { $config = \OC::$server->getSystemConfig(); $storage->propagator = new Propagator($storage, \OC::$server->getDatabaseConnection(), ['appdata_' . $config->getValue('instanceid')]); @@ -359,10 +367,19 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { return $storage->propagator; } + /** + * get a propagator instance for the cache + * + * @param \OC\Files\Storage\Storage $storage (optional) the storage to pass to the watcher + * @return Updater + */ public function getUpdater($storage = null) { if (!$storage) { $storage = $this; } + if (!$storage->instanceOfStorage(self::class)) { + throw new \InvalidArgumentException('Storage is not of the correct class'); + } if (!isset($storage->updater)) { $storage->updater = new Updater($storage); } diff --git a/lib/private/Files/Storage/Home.php b/lib/private/Files/Storage/Home.php index a8d1f82b987..0e53e7b28d4 100644 --- a/lib/private/Files/Storage/Home.php +++ b/lib/private/Files/Storage/Home.php @@ -52,13 +52,14 @@ class Home extends Local implements \OCP\Files\IHomeStorage { if (!isset($this->cache)) { $this->cache = new \OC\Files\Cache\HomeCache($storage, $this->getCacheDependencies()); } + /** @var \OC\Files\Cache\HomeCache */ return $this->cache; } /** * get a propagator instance for the cache * - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher + * @param \OC\Files\Storage\Storage $storage (optional) the storage to pass to the watcher * @return \OC\Files\Cache\Propagator */ public function getPropagator($storage = null) { @@ -68,6 +69,7 @@ class Home extends Local implements \OCP\Files\IHomeStorage { if (!isset($this->propagator)) { $this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection()); } + /** @var \OC\Files\Cache\Propagator */ return $this->propagator; } diff --git a/lib/private/Files/Storage/Storage.php b/lib/private/Files/Storage/Storage.php index 44b1a52cfc0..aff914ee12a 100644 --- a/lib/private/Files/Storage/Storage.php +++ b/lib/private/Files/Storage/Storage.php @@ -5,16 +5,18 @@ * SPDX-FileCopyrightText: 2016 ownCloud, Inc. * SPDX-License-Identifier: AGPL-3.0-only */ + namespace OC\Files\Storage; -use OCP\Lock\ILockingProvider; +use OCP\Files\Storage\ILockingStorage; +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 { +interface Storage extends IStorage, ILockingStorage { /** * get a cache instance for the storage * @@ -33,15 +35,6 @@ interface Storage extends \OCP\Files\Storage { */ 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 * @@ -79,30 +72,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 * * @param string $directory diff --git a/lib/private/Files/Storage/StorageFactory.php b/lib/private/Files/Storage/StorageFactory.php index 612592e2d3a..590425f5b64 100644 --- a/lib/private/Files/Storage/StorageFactory.php +++ b/lib/private/Files/Storage/StorageFactory.php @@ -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'); } } diff --git a/lib/private/Files/Storage/Temporary.php b/lib/private/Files/Storage/Temporary.php index 95ae84cb7d9..6c7ef4260c1 100644 --- a/lib/private/Files/Storage/Temporary.php +++ b/lib/private/Files/Storage/Temporary.php @@ -11,7 +11,7 @@ namespace OC\Files\Storage; * local storage backend in temporary folder for testing purpose */ class Temporary extends Local { - public function __construct($arguments = null) { + public function __construct($arguments = []) { parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]); } diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php index 11f21eb828e..a696a3e4802 100644 --- a/lib/private/Files/Storage/Wrapper/Encoding.php +++ b/lib/private/Files/Storage/Wrapper/Encoding.php @@ -382,16 +382,6 @@ class Encoding extends Wrapper { } /** - * search for occurrences of $query in file names - * - * @param string $query - * @return array|bool - */ - public function search($query) { - return $this->storage->search($query); - } - - /** * see https://www.php.net/manual/en/function.touch.php * If the backend does not support the operation, false should be returned * diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index 2e8306dc705..5673caf834a 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -322,16 +322,6 @@ class Jail extends Wrapper { } /** - * search for occurrences of $query in file names - * - * @param string $query - * @return array|bool - */ - public function search($query) { - return $this->getWrapperStorage()->search($query); - } - - /** * see https://www.php.net/manual/en/function.touch.php * If the backend does not support the operation, false should be returned * diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index f8aa9d963dc..f0420f4f16a 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -317,16 +317,6 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea } /** - * search for occurrences of $query in file names - * - * @param string $query - * @return array|bool - */ - public function search($query) { - return $this->getWrapperStorage()->search($query); - } - - /** * see https://www.php.net/manual/en/function.touch.php * If the backend does not support the operation, false should be returned * diff --git a/lib/public/Files/Storage.php b/lib/public/Files/Storage.php deleted file mode 100644 index 049841075ca..00000000000 --- a/lib/public/Files/Storage.php +++ /dev/null @@ -1,445 +0,0 @@ -<?php - -/** - * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2016 ownCloud, Inc. - * SPDX-License-Identifier: AGPL-3.0-only - */ -// use OCP namespace for all classes that are considered public. -// This means that they should be used by apps instead of the internal Nextcloud classes - -namespace OCP\Files; - -use OCP\Files\Storage\IStorage; -use OCP\Lock\ILockingProvider; - -/** - * 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. - * - * @since 6.0.0 - * @deprecated 9.0.0 use \OCP\Files\Storage\IStorage instead - */ -interface Storage extends IStorage { - /** - * $parameters is a free form array with the configuration options needed to construct the storage - * - * @param array $parameters - * @since 6.0.0 - */ - public function __construct($parameters); - - /** - * Get the identifier for the storage, - * the returned id should be the same for every storage object that is created with the same parameters - * and two storage objects with the same id should refer to two storages that display the same files. - * - * @return string - * @since 6.0.0 - */ - public function getId(); - - /** - * see https://www.php.net/manual/en/function.mkdir.php - * implementations need to implement a recursive mkdir - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function mkdir($path); - - /** - * see https://www.php.net/manual/en/function.rmdir.php - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function rmdir($path); - - /** - * see https://www.php.net/manual/en/function.opendir.php - * - * @param string $path - * @return resource|false - * @since 6.0.0 - */ - public function opendir($path); - - /** - * see https://www.php.net/manual/en/function.is-dir.php - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function is_dir($path); - - /** - * see https://www.php.net/manual/en/function.is-file.php - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function is_file($path); - - /** - * see https://www.php.net/manual/en/function.stat.php - * only the following keys are required in the result: size and mtime - * - * @param string $path - * @return array|bool - * @since 6.0.0 - */ - public function stat($path); - - /** - * see https://www.php.net/manual/en/function.filetype.php - * - * @param string $path - * @return string|bool - * @since 6.0.0 - */ - public function filetype($path); - - /** - * see https://www.php.net/manual/en/function.filesize.php - * The result for filesize when called on a folder is required to be 0 - * - * @param string $path - * @return false|int|float - * @since 6.0.0 - */ - public function filesize($path); - - /** - * check if a file can be created in $path - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function isCreatable($path); - - /** - * check if a file can be read - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function isReadable($path); - - /** - * check if a file can be written to - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function isUpdatable($path); - - /** - * check if a file can be deleted - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function isDeletable($path); - - /** - * check if a file can be shared - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function isSharable($path); - - /** - * get the full permissions of a path. - * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php - * - * @param string $path - * @return int - * @since 6.0.0 - */ - public function getPermissions($path); - - /** - * see https://www.php.net/manual/en/function.file_exists.php - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function file_exists($path); - - /** - * see https://www.php.net/manual/en/function.filemtime.php - * - * @param string $path - * @return int|bool - * @since 6.0.0 - */ - public function filemtime($path); - - /** - * see https://www.php.net/manual/en/function.file_get_contents.php - * - * @param string $path - * @return string|false - * @since 6.0.0 - */ - public function file_get_contents($path); - - /** - * see https://www.php.net/manual/en/function.file_put_contents.php - * - * @param string $path - * @param mixed $data - * @return int|float|false - * @since 6.0.0 - */ - public function file_put_contents($path, $data); - - /** - * see https://www.php.net/manual/en/function.unlink.php - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function unlink($path); - - /** - * see https://www.php.net/manual/en/function.rename.php - * - * @param string $source - * @param string $target - * @return bool - * @since 6.0.0 - */ - public function rename($source, $target); - - /** - * see https://www.php.net/manual/en/function.copy.php - * - * @param string $source - * @param string $target - * @return bool - * @since 6.0.0 - */ - public function copy($source, $target); - - /** - * see https://www.php.net/manual/en/function.fopen.php - * - * @param string $path - * @param string $mode - * @return resource|bool - * @since 6.0.0 - */ - public function fopen($path, $mode); - - /** - * get the mimetype for a file or folder - * The mimetype for a folder is required to be "httpd/unix-directory" - * - * @param string $path - * @return string|bool - * @since 6.0.0 - */ - public function getMimeType($path); - - /** - * see https://www.php.net/manual/en/function.hash-file.php - * - * @param string $type - * @param string $path - * @param bool $raw - * @return string|bool - * @since 6.0.0 - */ - public function hash($type, $path, $raw = false); - - /** - * see https://www.php.net/manual/en/function.disk-free-space.php - * - * @param string $path - * @return int|float|bool - * @since 6.0.0 - */ - 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 - * - * @param string $path - * @param int $mtime - * @return bool - * @since 6.0.0 - */ - public function touch($path, $mtime = null); - - /** - * get the path to a local version of the file. - * The local version of the file can be temporary and doesn't have to be persistent across requests - * - * @param string $path - * @return string|false - * @since 6.0.0 - */ - public function getLocalFile($path); - - /** - * check if a file or folder has been updated since $time - * - * @param string $path - * @param int $time - * @return bool - * @since 6.0.0 - * - * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. - * returning true for other changes in the folder is optional - */ - public function hasUpdated($path, $time); - - /** - * get the ETag for a file or folder - * - * @param string $path - * @return string|false - * @since 6.0.0 - */ - public function getETag($path); - - /** - * Returns whether the storage is local, which means that files - * are stored on the local filesystem instead of remotely. - * Calling getLocalFile() for local storages should always - * return the local files, whereas for non-local storages - * it might return a temporary file. - * - * @return bool true if the files are stored locally, false otherwise - * @since 7.0.0 - */ - public function isLocal(); - - /** - * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class - * - * @template T of IStorage - * @param string $class - * @psalm-param class-string<T> $class - * @return bool - * @since 7.0.0 - * @psalm-assert-if-true T $this - */ - public function instanceOfStorage($class); - - /** - * A custom storage implementation can return an url for direct download of a give file. - * - * For now the returned array can hold the parameter url - in future more attributes might follow. - * - * @param string $path - * @return array|bool - * @since 8.0.0 - */ - public function getDirectDownload($path); - - /** - * @param string $path the path of the target folder - * @param string $fileName the name of the file itself - * @return void - * @throws InvalidPathException - * @since 8.1.0 - */ - public function verifyPath($path, $fileName); - - /** - * @param IStorage $sourceStorage - * @param string $sourceInternalPath - * @param string $targetInternalPath - * @return bool - * @since 8.1.0 - */ - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath); - - /** - * @param IStorage $sourceStorage - * @param string $sourceInternalPath - * @param string $targetInternalPath - * @return bool - * @since 8.1.0 - */ - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath); - - /** - * @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 - * @since 8.1.0 - */ - public function acquireLock($path, $type, ILockingProvider $provider); - - /** - * @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 - * @since 8.1.0 - */ - 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 - * @since 8.1.0 - */ - public function changeLock($path, $type, ILockingProvider $provider); - - /** - * Test a storage for availability - * - * @since 8.2.0 - * @return bool - */ - public function test(); - - /** - * @since 8.2.0 - * @return array [ available, last_checked ] - */ - public function getAvailability(); - - /** - * @since 8.2.0 - * @param bool $isAvailable - */ - public function setAvailability($isAvailable); - - /** - * @since 12.0.0 - * @return mixed - */ - public function needsPartFile(); -} diff --git a/lib/public/Files/Storage/IStorage.php b/lib/public/Files/Storage/IStorage.php index e18d6768346..d2fd3b75553 100644 --- a/lib/public/Files/Storage/IStorage.php +++ b/lib/public/Files/Storage/IStorage.php @@ -401,11 +401,20 @@ interface IStorage { /** * @since 9.0.0 * @param bool $isAvailable + * @return void */ public function setAvailability($isAvailable); /** + * @since 12.0.0 + * @since 31.0.0 moved from Storage to IStorage + * @return bool + */ + public function needsPartFile(); + + /** * @param string $path path for which to retrieve the owner + * @return string * @since 9.0.0 */ public function getOwner($path); diff --git a/lib/public/Files/Storage/IStorageFactory.php b/lib/public/Files/Storage/IStorageFactory.php index e0ec3128876..6d44b39274e 100644 --- a/lib/public/Files/Storage/IStorageFactory.php +++ b/lib/public/Files/Storage/IStorageFactory.php @@ -28,10 +28,10 @@ interface IStorageFactory { public function addStorageWrapper($wrapperName, $callback); /** - * @param \OCP\Files\Mount\IMountPoint $mountPoint + * @param IMountPoint $mountPoint * @param string $class * @param array $arguments - * @return \OCP\Files\Storage + * @return IStorage * @since 8.0.0 */ public function getInstance(IMountPoint $mountPoint, $class, $arguments); |