mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
Merge pull request #48009 from nextcloud/fix/remove-references-to-deprected-storage-interface
fix: Remove OCP\Files\Storage interface deprecated since version 9
This commit is contained in:
commit
b9fb1db0f8
38 changed files with 167 additions and 656 deletions
|
|
@ -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;
|
||||
|
|
@ -72,11 +72,8 @@ class FileTest extends TestCase {
|
|||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockObject|Storage
|
||||
*/
|
||||
private function getMockStorage() {
|
||||
$storage = $this->getMockBuilder(Storage::class)
|
||||
private function getMockStorage(): MockObject&IStorage {
|
||||
$storage = $this->getMockBuilder(IStorage::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$storage->method('getId')
|
||||
|
|
@ -84,10 +81,7 @@ class FileTest extends TestCase {
|
|||
return $storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
*/
|
||||
private function getStream($string) {
|
||||
private function getStream(string $string) {
|
||||
$stream = fopen('php://temp', 'r+');
|
||||
fwrite($stream, $string);
|
||||
fseek($stream, 0);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1
apps/files_sharing/lib/External/Storage.php
vendored
1
apps/files_sharing/lib/External/Storage.php
vendored
|
|
@ -149,6 +149,7 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
|
|||
if (!isset($this->scanner)) {
|
||||
$this->scanner = new Scanner($storage);
|
||||
}
|
||||
/** @var \OCA\Files_Sharing\External\Scanner */
|
||||
return $this->scanner;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use OCP\Files\IRootFolder;
|
|||
use OCP\Files\Node;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\NotPermittedException;
|
||||
use OCP\Files\Storage\ILockingStorage;
|
||||
use OCP\FilesMetadata\IFilesMetadataManager;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
|
|
@ -118,7 +119,7 @@ class Trashbin {
|
|||
* @param string $user
|
||||
* @param string $filename
|
||||
* @param string $timestamp
|
||||
* @return string original location
|
||||
* @return string|false original location
|
||||
*/
|
||||
public static function getLocation($user, $filename, $timestamp) {
|
||||
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
|
||||
|
|
@ -139,7 +140,8 @@ class Trashbin {
|
|||
}
|
||||
}
|
||||
|
||||
private static function setUpTrash($user) {
|
||||
/** @param string $user */
|
||||
private static function setUpTrash($user): void {
|
||||
$view = new View('/' . $user);
|
||||
if (!$view->is_dir('files_trashbin')) {
|
||||
$view->mkdir('files_trashbin');
|
||||
|
|
@ -162,10 +164,10 @@ class Trashbin {
|
|||
* @param string $sourcePath
|
||||
* @param string $owner
|
||||
* @param string $targetPath
|
||||
* @param $user
|
||||
* @param string $user
|
||||
* @param int $timestamp
|
||||
*/
|
||||
private static function copyFilesToUser($sourcePath, $owner, $targetPath, $user, $timestamp) {
|
||||
private static function copyFilesToUser($sourcePath, $owner, $targetPath, $user, $timestamp): void {
|
||||
self::setUpTrash($owner);
|
||||
|
||||
$targetFilename = basename($targetPath);
|
||||
|
|
@ -256,7 +258,7 @@ class Trashbin {
|
|||
|
||||
while (!$gotLock) {
|
||||
try {
|
||||
/** @var \OC\Files\Storage\Storage $trashStorage */
|
||||
/** @var ILockingStorage $trashStorage */
|
||||
[$trashStorage, $trashInternalPath] = $ownerView->resolvePath($trashPath);
|
||||
|
||||
$trashStorage->acquireLock($trashInternalPath, ILockingProvider::LOCK_EXCLUSIVE, $lockingProvider);
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
@ -78,30 +71,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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -381,16 +381,6 @@ class Encoding extends Wrapper {
|
|||
return $this->storage->free_space($this->findPathToUse($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -321,16 +321,6 @@ class Jail extends Wrapper {
|
|||
return $this->getWrapperStorage()->free_space($this->getUnjailedPath($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -316,16 +316,6 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
|
|||
return $this->getWrapperStorage()->free_space($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,8 @@ namespace Test\Encryption;
|
|||
use OC\Encryption\EncryptionWrapper;
|
||||
use OC\Encryption\Manager;
|
||||
use OC\Memcache\ArrayCache;
|
||||
use OCP\Files\Storage;
|
||||
use OCP\Files\Storage\IDisableEncryptionStorage;
|
||||
use OCP\Files\Storage\IStorage;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -42,7 +43,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();
|
||||
|
||||
|
|
@ -74,7 +75,7 @@ class EncryptionWrapperTest extends TestCase {
|
|||
[true, ['OCA\Files_Trashbin\Storage']],
|
||||
|
||||
// Do not wrap shared storages
|
||||
[false, [Storage\IDisableEncryptionStorage::class]],
|
||||
[false, [IDisableEncryptionStorage::class]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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…
Reference in a new issue