fix: Remove OCP\Files\Storage interface deprecated since version 9

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/48009/head
Côme Chilliet 8 months ago
parent dde0b48c93
commit 801733e523
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
  1. 14
      apps/dav/lib/Connector/Sabre/File.php
  2. 6
      apps/dav/tests/unit/Connector/Sabre/FileTest.php
  3. 8
      apps/dav/tests/unit/Connector/Sabre/NodeTest.php
  4. 8
      apps/encryption/tests/Crypto/EncryptionTest.php
  5. 4
      apps/encryption/tests/KeyManagerTest.php
  6. 4
      apps/encryption/tests/UtilTest.php
  7. 20
      apps/files_external/lib/Config/ConfigAdapter.php
  8. 4
      apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
  9. 12
      apps/files_external/lib/Lib/StorageModifierTrait.php
  10. 32
      apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
  11. 445
      lib/public/Files/Storage.php
  12. 4
      lib/public/Files/Storage/IStorageFactory.php
  13. 6
      tests/lib/Encryption/DecryptAllTest.php
  14. 4
      tests/lib/Encryption/EncryptionWrapperTest.php
  15. 4
      tests/lib/Files/Mount/MountPointTest.php
  16. 18
      tests/lib/Files/Node/FolderTest.php
  17. 4
      tests/lib/Files/Node/NodeTest.php
  18. 6
      tests/lib/Lockdown/Filesystem/NullStorageTest.php
  19. 26
      tests/lib/Share20/ManagerTest.php

@ -28,7 +28,7 @@ use OCP\Files\InvalidPathException;
use OCP\Files\LockNotAcquiredException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\Storage;
use OCP\Files\Storage\IWriteStreamStorage;
use OCP\Files\StorageNotAvailableException;
use OCP\IL10N;
use OCP\IRequest;
@ -117,8 +117,10 @@ class File extends Node implements IFile {
// verify path of the target
$this->verifyPath();
/** @var Storage $partStorage */
[$partStorage] = $this->fileView->resolvePath($this->path);
if ($partStorage === null) {
throw new ServiceUnavailable($this->l10n->t('Failed to get storage for file'));
}
$needsPartFile = $partStorage->needsPartFile() && (strlen($this->path) > 1);
$view = \OC\Files\Filesystem::getView();
@ -141,10 +143,11 @@ class File extends Node implements IFile {
}
// the part file and target file might be on a different storage in case of a single file storage (e.g. single file share)
/** @var \OC\Files\Storage\Storage $partStorage */
[$partStorage, $internalPartPath] = $this->fileView->resolvePath($partFilePath);
/** @var \OC\Files\Storage\Storage $storage */
[$storage, $internalPath] = $this->fileView->resolvePath($this->path);
if ($partStorage === null || $storage === null) {
throw new ServiceUnavailable($this->l10n->t('Failed to get storage for file'));
}
try {
if (!$needsPartFile) {
try {
@ -196,7 +199,7 @@ class File extends Node implements IFile {
}
}
if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) {
if ($partStorage->instanceOfStorage(IWriteStreamStorage::class)) {
$isEOF = false;
$wrappedData = CallbackWrapper::wrap($data, null, null, null, null, function ($stream) use (&$isEOF) {
$isEOF = feof($stream);
@ -535,7 +538,6 @@ class File extends Node implements IFile {
if (\OCP\Server::get(\OCP\App\IAppManager::class)->isEnabledForUser('encryption')) {
return [];
}
/** @var \OCP\Files\Storage $storage */
[$storage, $internalPath] = $this->fileView->resolvePath($this->path);
if (is_null($storage)) {
return [];

@ -17,7 +17,7 @@ use OCA\DAV\Connector\Sabre\File;
use OCP\Constants;
use OCP\Files\FileInfo;
use OCP\Files\ForbiddenException;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use OCP\IConfig;
use OCP\IRequestId;
use OCP\ITempManager;
@ -73,10 +73,10 @@ class FileTest extends TestCase {
}
/**
* @return MockObject|Storage
* @return MockObject|IStorage
*/
private function getMockStorage() {
$storage = $this->getMockBuilder(Storage::class)
$storage = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()
->getMock();
$storage->method('getId')

@ -18,7 +18,7 @@ use OCA\Files_Sharing\SharedStorage;
use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use OCP\ICache;
use OCP\Share\IManager;
use OCP\Share\IShare;
@ -75,7 +75,7 @@ class NodeTest extends \Test\TestCase {
return $this->createMock(MountPoint::class);
}
});
$storage = $this->createMock(Storage\IStorage::class);
$storage = $this->createMock(IStorage::class);
if ($shared) {
$storage->method('instanceOfStorage')
->willReturn(true);
@ -145,7 +145,7 @@ class NodeTest extends \Test\TestCase {
* @dataProvider sharePermissionsProvider
*/
public function testSharePermissions($type, $user, $permissions, $expected): void {
$storage = $this->getMockBuilder(Storage::class)
$storage = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()
->getMock();
$storage->method('getPermissions')->willReturn($permissions);
@ -223,7 +223,7 @@ class NodeTest extends \Test\TestCase {
}
public function testShareAttributesNonShare(): void {
$storage = $this->getMockBuilder(Storage::class)
$storage = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()
->getMock();

@ -15,8 +15,9 @@ use OCA\Encryption\Exceptions\PublicKeyMissingException;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Session;
use OCA\Encryption\Util;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use OCP\IL10N;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -50,13 +51,12 @@ class EncryptionTest extends TestCase {
/** @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject */
private $l10nMock;
/** @var \OCP\Files\Storage|\PHPUnit\Framework\MockObject\MockObject */
private $storageMock;
private IStorage&MockObject $storageMock;
protected function setUp(): void {
parent::setUp();
$this->storageMock = $this->getMockBuilder(Storage::class)
$this->storageMock = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()->getMock();
$this->cryptMock = $this->getMockBuilder(Crypt::class)
->disableOriginalConstructor()

@ -15,7 +15,7 @@ use OCA\Encryption\Session;
use OCA\Encryption\Util;
use OCP\Encryption\Keys\IStorage;
use OCP\Files\Cache\ICache;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage as FilesIStorage;
use OCP\IConfig;
use OCP\IUserSession;
use OCP\Lock\ILockingProvider;
@ -687,7 +687,7 @@ class KeyManagerTest extends TestCase {
$cache->expects($this->once())
->method('update')
->with(123, ['encrypted' => 5, 'encryptedVersion' => 5]);
$storage = $this->getMockBuilder(Storage::class)
$storage = $this->getMockBuilder(FilesIStorage::class)
->disableOriginalConstructor()->getMock();
$storage->expects($this->once())
->method('getCache')

@ -11,7 +11,7 @@ use OC\Files\View;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Util;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
@ -181,7 +181,7 @@ class UtilTest extends TestCase {
}
public function testGetStorage(): void {
$return = $this->getMockBuilder(Storage::class)
$return = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()
->getMock();

@ -14,7 +14,8 @@ use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\UserGlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Storage;
use OCP\Files\ObjectStore\IObjectStore;
use OCP\Files\Storage\IStorage;
use OCP\Files\Storage\IStorageFactory;
use OCP\Files\StorageNotAvailableException;
use OCP\IUser;
@ -34,11 +35,9 @@ class ConfigAdapter implements IMountProvider {
/**
* Process storage ready for mounting
*
* @param StorageConfig $storage
* @param IUser $user
* @throws \OCP\AppFramework\QueryException
*/
private function prepareStorageConfig(StorageConfig &$storage, IUser $user) {
private function prepareStorageConfig(StorageConfig &$storage, IUser $user): void {
foreach ($storage->getBackendOptions() as $option => $value) {
$storage->setBackendOption($option, \OCA\Files_External\MountConfig::substitutePlaceholdersInConfig($value, $user->getUID()));
}
@ -46,7 +45,7 @@ class ConfigAdapter implements IMountProvider {
$objectStore = $storage->getBackendOption('objectstore');
if ($objectStore) {
$objectClass = $objectStore['class'];
if (!is_subclass_of($objectClass, '\OCP\Files\ObjectStore\IObjectStore')) {
if (!is_subclass_of($objectClass, IObjectStore::class)) {
throw new \InvalidArgumentException('Invalid object store');
}
$storage->setBackendOption('objectstore', new $objectClass($objectStore));
@ -60,9 +59,8 @@ class ConfigAdapter implements IMountProvider {
* Construct the storage implementation
*
* @param StorageConfig $storageConfig
* @return Storage
*/
private function constructStorage(StorageConfig $storageConfig) {
private function constructStorage(StorageConfig $storageConfig): IStorage {
$class = $storageConfig->getBackend()->getStorageClass();
$storage = new $class($storageConfig->getBackendOptions());
@ -76,8 +74,6 @@ class ConfigAdapter implements IMountProvider {
/**
* Get all mountpoints applicable for the user
*
* @param \OCP\IUser $user
* @param \OCP\Files\Storage\IStorageFactory $loader
* @return \OCP\Files\Mount\IMountPoint[]
*/
public function getMountsForUser(IUser $user, IStorageFactory $loader) {
@ -97,11 +93,11 @@ class ConfigAdapter implements IMountProvider {
}, $storageConfigs);
\OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function (Storage\IStorage $storage) {
\OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function (IStorage $storage) {
return $storage->getId();
}, $storages));
$availableStorages = array_map(function (Storage\IStorage $storage, StorageConfig $storageConfig) {
$availableStorages = array_map(function (IStorage $storage, StorageConfig $storageConfig): IStorage {
try {
$availability = $storage->getAvailability();
if (!$availability['available'] && !Availability::shouldRecheck($availability)) {
@ -116,7 +112,7 @@ class ConfigAdapter implements IMountProvider {
return $storage;
}, $storages, $storageConfigs);
$mounts = array_map(function (StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
$mounts = array_map(function (StorageConfig $storageConfig, IStorage $storage) use ($user, $loader) {
$storage->setOwner($user->getUID());
if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAL) {
return new PersonalMount(

@ -12,7 +12,7 @@ use OCA\Files_External\Lib\SessionStorageWrapper;
use OCA\Files_External\Lib\StorageConfig;
use OCP\Authentication\Exceptions\CredentialsUnavailableException;
use OCP\Authentication\LoginCredentials\IStore as CredentialsStore;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use OCP\Files\StorageAuthException;
use OCP\IL10N;
use OCP\IUser;
@ -56,7 +56,7 @@ class SessionCredentials extends AuthMechanism {
$storage->setBackendOption('password', $credentials->getPassword());
}
public function wrapStorage(Storage $storage) {
public function wrapStorage(IStorage $storage): IStorage {
return new SessionStorageWrapper(['storage' => $storage]);
}
}

@ -6,7 +6,7 @@
*/
namespace OCA\Files_External\Lib;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use OCP\Files\StorageNotAvailableException;
use OCP\IUser;
@ -28,8 +28,8 @@ trait StorageModifierTrait {
/**
* Modify a StorageConfig parameters
*
* @param StorageConfig $storage
* @param IUser $user User the storage is being used as
* @param StorageConfig &$storage
* @param ?IUser $user User the storage is being used as
* @return void
* @throws InsufficientDataForMeaningfulAnswerException
* @throws StorageNotAvailableException
@ -38,14 +38,12 @@ trait StorageModifierTrait {
}
/**
* Wrap a Storage if necessary
* Wrap a storage if necessary
*
* @param Storage $storage
* @return Storage
* @throws InsufficientDataForMeaningfulAnswerException
* @throws StorageNotAvailableException
*/
public function wrapStorage(Storage $storage) {
public function wrapStorage(IStorage $storage): IStorage {
return $storage;
}
}

@ -16,7 +16,7 @@ use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use OCP\IConfig;
use OCP\IDateTimeZone;
use OCP\IGroup;
@ -526,7 +526,7 @@ class ShareAPIControllerTest extends TestCase {
->getMock();
$cache->method('getNumericStorageId')->willReturn(101);
$storage = $this->getMockBuilder(Storage::class)
$storage = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()
->getMock();
$storage->method('getId')->willReturn('STORAGE');
@ -1923,7 +1923,7 @@ class ShareAPIControllerTest extends TestCase {
$path = $this->getMockBuilder(Folder::class)->getMock();
$path->method('getId')->willReturn(42);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],
@ -1947,7 +1947,7 @@ class ShareAPIControllerTest extends TestCase {
$path = $this->getMockBuilder(Folder::class)->getMock();
$path->method('getId')->willReturn(42);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],
@ -1972,7 +1972,7 @@ class ShareAPIControllerTest extends TestCase {
$path = $this->getMockBuilder(File::class)->getMock();
$path->method('getId')->willReturn(42);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],
@ -1996,7 +1996,7 @@ class ShareAPIControllerTest extends TestCase {
$path = $this->getMockBuilder(Folder::class)->getMock();
$path->method('getId')->willReturn(1);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],
@ -2035,7 +2035,7 @@ class ShareAPIControllerTest extends TestCase {
$path = $this->getMockBuilder(Folder::class)->getMock();
$path->method('getId')->willReturn(42);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],
@ -2074,7 +2074,7 @@ class ShareAPIControllerTest extends TestCase {
$path = $this->getMockBuilder(Folder::class)->getMock();
$path->method('getId')->willReturn(42);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],
@ -2120,7 +2120,7 @@ class ShareAPIControllerTest extends TestCase {
$path = $this->getMockBuilder(Folder::class)->getMock();
$path->method('getId')->willReturn(42);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],
@ -2159,7 +2159,7 @@ class ShareAPIControllerTest extends TestCase {
$path = $this->getMockBuilder(Folder::class)->getMock();
$path->method('getId')->willReturn(42);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],
@ -2205,7 +2205,7 @@ class ShareAPIControllerTest extends TestCase {
$path = $this->getMockBuilder(Folder::class)->getMock();
$path->method('getId')->willReturn(42);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],
@ -2574,7 +2574,7 @@ class ShareAPIControllerTest extends TestCase {
$path = $this->getMockBuilder(Folder::class)->getMock();
$path->method('getId')->willReturn(42);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', true],
@ -3762,7 +3762,7 @@ class ShareAPIControllerTest extends TestCase {
$cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock();
$cache->method('getNumericStorageId')->willReturn(100);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('getId')->willReturn('storageId');
$storage->method('getCache')->willReturn($cache);
@ -4759,7 +4759,7 @@ class ShareAPIControllerTest extends TestCase {
$cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock();
$cache->method('getNumericStorageId')->willReturn(100);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('getId')->willReturn('storageId');
$storage->method('getCache')->willReturn($cache);
@ -4923,7 +4923,7 @@ class ShareAPIControllerTest extends TestCase {
private function getNonSharedUserFolder(): array {
$node = $this->getMockBuilder(Folder::class)->getMock();
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],
@ -4938,7 +4938,7 @@ class ShareAPIControllerTest extends TestCase {
private function getNonSharedUserFile(): array {
$node = $this->getMockBuilder(File::class)->getMock();
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
['OCA\Files_Sharing\External\Storage', false],

@ -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();
}

@ -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);

@ -12,7 +12,7 @@ use OC\Encryption\Exceptions\DecryptionFailedException;
use OC\Encryption\Manager;
use OC\Files\FileInfo;
use OC\Files\View;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use OCP\IUserManager;
use OCP\UserInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
@ -246,11 +246,11 @@ class DecryptAllTest extends TestCase {
->setMethods(['decryptFile'])
->getMock();
$storage = $this->getMockBuilder(Storage::class)
$storage = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()->getMock();
$sharedStorage = $this->getMockBuilder(Storage::class)
$sharedStorage = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()->getMock();
$sharedStorage->expects($this->once())->method('instanceOfStorage')

@ -10,7 +10,7 @@ namespace Test\Encryption;
use OC\Encryption\EncryptionWrapper;
use OC\Encryption\Manager;
use OC\Memcache\ArrayCache;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@ -42,7 +42,7 @@ class EncryptionWrapperTest extends TestCase {
* @dataProvider provideWrapStorage
*/
public function testWrapStorage($expectedWrapped, $wrappedStorages): void {
$storage = $this->getMockBuilder(Storage::class)
$storage = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()
->getMock();

@ -8,14 +8,14 @@
namespace Test\Files\Mount;
use OC\Files\Storage\StorageFactory;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
class DummyStorage {
}
class MountPointTest extends \Test\TestCase {
public function testGetStorage(): void {
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->expects($this->once())
->method('getId')
->willReturn(123);

@ -28,7 +28,7 @@ use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
use OCP\Files\Search\ISearchComparison;
use OCP\Files\Search\ISearchOrder;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use PHPUnit\Framework\MockObject\MockObject;
/**
@ -292,7 +292,7 @@ class FolderTest extends NodeTest {
$root->method('getUser')
->willReturn($this->user);
/** @var Storage\IStorage&MockObject $storage */
$storage = $this->createMock(Storage\IStorage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('getId')->willReturn('test::1');
$cache = new Cache($storage);
@ -341,7 +341,7 @@ class FolderTest extends NodeTest {
->method('getUser')
->willReturn($this->user);
/** @var \PHPUnit\Framework\MockObject\MockObject|Storage $storage */
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('getId')->willReturn('test::2');
$cache = new Cache($storage);
@ -379,7 +379,7 @@ class FolderTest extends NodeTest {
->getMock();
$root->method('getUser')
->willReturn($this->user);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('getId')->willReturn('test::1');
$cache = new Cache($storage);
@ -420,10 +420,10 @@ class FolderTest extends NodeTest {
$root->expects($this->any())
->method('getUser')
->willReturn($this->user);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('getId')->willReturn('test::1');
$cache = new Cache($storage);
$subStorage = $this->createMock(Storage::class);
$subStorage = $this->createMock(IStorage::class);
$subStorage->method('getId')->willReturn('test::2');
$subCache = new Cache($subStorage);
$subMount = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([Temporary::class, ''])->getMock();
@ -922,14 +922,14 @@ class FolderTest extends NodeTest {
$root->expects($this->any())
->method('getUser')
->willReturn($this->user);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('getId')->willReturn('test::1');
$cache = new Cache($storage);
$subStorage1 = $this->createMock(Storage::class);
$subStorage1 = $this->createMock(IStorage::class);
$subStorage1->method('getId')->willReturn('test::2');
$subCache1 = new Cache($subStorage1);
$subMount1 = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([Temporary::class, ''])->getMock();
$subStorage2 = $this->createMock(Storage::class);
$subStorage2 = $this->createMock(IStorage::class);
$subStorage2->method('getId')->willReturn('test::3');
$subCache2 = new Cache($subStorage2);
$subMount2 = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([Temporary::class, ''])->getMock();

@ -16,7 +16,7 @@ use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use OCP\ICacheFactory;
use OCP\IUser;
use OCP\IUserManager;
@ -111,7 +111,7 @@ abstract class NodeTest extends \Test\TestCase {
abstract protected function getViewDeleteMethod();
protected function getMockStorage() {
$storage = $this->getMockBuilder(Storage::class)
$storage = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()
->getMock();
$storage->expects($this->any())

@ -11,7 +11,7 @@ use OC\Files\FileInfo;
use OC\ForbiddenException;
use OC\Lockdown\Filesystem\NullCache;
use OC\Lockdown\Filesystem\NullStorage;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use Test\TestCase;
class NullStorageTest extends TestCase {
@ -196,7 +196,7 @@ class NullStorageTest extends TestCase {
}
public function testCopyFromStorage(): void {
$sourceStorage = $this->createMock(Storage::class);
$sourceStorage = $this->createMock(IStorage::class);
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
@ -205,7 +205,7 @@ class NullStorageTest extends TestCase {
}
public function testMoveFromStorage(): void {
$sourceStorage = $this->createMock(Storage::class);
$sourceStorage = $this->createMock(IStorage::class);
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');

@ -23,7 +23,7 @@ use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Node;
use OCP\Files\Storage;
use OCP\Files\Storage\IStorage;
use OCP\HintException;
use OCP\IConfig;
use OCP\IDateTimeZone;
@ -631,7 +631,7 @@ class ManagerTest extends \Test\TestCase {
$file = $this->createMock(File::class);
$node = $this->createMock(Node::class);
$storage = $this->createMock(Storage\IStorage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->with('\OCA\Files_Sharing\External\Storage')
->willReturn(false);
@ -706,7 +706,7 @@ class ManagerTest extends \Test\TestCase {
$data[] = [$this->createShare(null, IShare::TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Cannot increase permissions of path', true];
$data[] = [$this->createShare(null, IShare::TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Cannot increase permissions of path', true];
$nonMovableStorage = $this->createMock(Storage\IStorage::class);
$nonMovableStorage = $this->createMock(IStorage::class);
$nonMovableStorage->method('instanceOfStorage')
->with('\OCA\Files_Sharing\External\Storage')
->willReturn(false);
@ -752,7 +752,7 @@ class ManagerTest extends \Test\TestCase {
$data[] = [$this->createShare(null, IShare::TYPE_LINK, $allPermssions, null, $user0, $user0, 17, null, null), null, false];
$remoteStorage = $this->createMock(Storage\IStorage::class);
$remoteStorage = $this->createMock(IStorage::class);
$remoteStorage->method('instanceOfStorage')
->with('\OCA\Files_Sharing\External\Storage')
->willReturn(true);
@ -2059,7 +2059,7 @@ class ManagerTest extends \Test\TestCase {
$path->method('getPath')->willReturn('path');
$mount = $this->createMock(IMountPoint::class);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$mount->method('getStorage')->willReturn($storage);
$storage->method('instanceOfStorage')->with('\OCA\Files_Sharing\ISharedStorage')->willReturn(true);
@ -2073,7 +2073,7 @@ class ManagerTest extends \Test\TestCase {
$path->method('getPath')->willReturn('path');
$mount = $this->createMock(IMountPoint::class);
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$mount->method('getStorage')->willReturn($storage);
$storage->method('instanceOfStorage')->with('\OCA\Files_Sharing\ISharedStorage')->willReturn(false);
@ -2221,7 +2221,7 @@ class ManagerTest extends \Test\TestCase {
$shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$path = $this->createMock(File::class);
$path->method('getOwner')->willReturn($shareOwner);
$path->method('getName')->willReturn('target');
@ -2276,7 +2276,7 @@ class ManagerTest extends \Test\TestCase {
$shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$path = $this->createMock(File::class);
$path->method('getOwner')->willReturn($shareOwner);
$path->method('getName')->willReturn('target');
@ -2339,7 +2339,7 @@ class ManagerTest extends \Test\TestCase {
$shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$path = $this->createMock(File::class);
$path->method('getOwner')->willReturn($shareOwner);
$path->method('getName')->willReturn('target');
@ -2459,7 +2459,7 @@ class ManagerTest extends \Test\TestCase {
$shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$path = $this->createMock(File::class);
$path->method('getOwner')->willReturn($shareOwner);
$path->method('getName')->willReturn('target');
@ -2563,7 +2563,7 @@ class ManagerTest extends \Test\TestCase {
$shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$path = $this->createMock(File::class);
$path->method('getOwner')->willReturn($shareOwner);
$path->method('getName')->willReturn('target');
@ -2623,12 +2623,12 @@ class ManagerTest extends \Test\TestCase {
$shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->willReturn('shareOwner');
$storage = $this->createMock(Storage::class);
$storage = $this->createMock(IStorage::class);
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(true);
$storage2 = $this->createMock(Storage::class);
$storage2 = $this->createMock(IStorage::class);
$storage2->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);

Loading…
Cancel
Save