mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: Fix other uses of removed Storage interface
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
801733e523
commit
22822d5e9b
7 changed files with 30 additions and 95 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
||||
|
|
|
|||
|
|
@ -5,68 +5,17 @@
|
|||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace OC\Files\Storage;
|
||||
|
||||
use OCP\Lock\ILockingProvider;
|
||||
use OCP\Files\Storage\IStorage;
|
||||
|
||||
/**
|
||||
* Provide a common interface to all different storage options
|
||||
*
|
||||
* All paths passed to the storage are relative to the storage and should NOT have a leading slash.
|
||||
*/
|
||||
interface Storage extends \OCP\Files\Storage {
|
||||
/**
|
||||
* get a cache instance for the storage
|
||||
*
|
||||
* @param string $path
|
||||
* @param \OC\Files\Storage\Storage|null (optional) the storage to pass to the cache
|
||||
* @return \OC\Files\Cache\Cache
|
||||
*/
|
||||
public function getCache($path = '', $storage = null);
|
||||
|
||||
/**
|
||||
* get a scanner instance for the storage
|
||||
*
|
||||
* @param string $path
|
||||
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
|
||||
* @return \OC\Files\Cache\Scanner
|
||||
*/
|
||||
public function getScanner($path = '', $storage = null);
|
||||
|
||||
|
||||
/**
|
||||
* get the user id of the owner of a file or folder
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getOwner($path);
|
||||
|
||||
/**
|
||||
* get a watcher instance for the cache
|
||||
*
|
||||
* @param string $path
|
||||
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
|
||||
* @return \OC\Files\Cache\Watcher
|
||||
*/
|
||||
public function getWatcher($path = '', $storage = null);
|
||||
|
||||
/**
|
||||
* get a propagator instance for the cache
|
||||
*
|
||||
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
|
||||
* @return \OC\Files\Cache\Propagator
|
||||
*/
|
||||
public function getPropagator($storage = null);
|
||||
|
||||
/**
|
||||
* get a updater instance for the cache
|
||||
*
|
||||
* @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
|
||||
* @return \OC\Files\Cache\Updater
|
||||
*/
|
||||
public function getUpdater($storage = null);
|
||||
|
||||
interface Storage extends IStorage {
|
||||
/**
|
||||
* @return \OC\Files\Cache\Storage
|
||||
*/
|
||||
|
|
@ -78,30 +27,6 @@ interface Storage extends \OCP\Files\Storage {
|
|||
*/
|
||||
public function getMetaData($path);
|
||||
|
||||
/**
|
||||
* @param string $path The path of the file to acquire the lock for
|
||||
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
|
||||
* @param \OCP\Lock\ILockingProvider $provider
|
||||
* @throws \OCP\Lock\LockedException
|
||||
*/
|
||||
public function acquireLock($path, $type, ILockingProvider $provider);
|
||||
|
||||
/**
|
||||
* @param string $path The path of the file to release the lock for
|
||||
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
|
||||
* @param \OCP\Lock\ILockingProvider $provider
|
||||
* @throws \OCP\Lock\LockedException
|
||||
*/
|
||||
public function releaseLock($path, $type, ILockingProvider $provider);
|
||||
|
||||
/**
|
||||
* @param string $path The path of the file to change the lock for
|
||||
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
|
||||
* @param \OCP\Lock\ILockingProvider $provider
|
||||
* @throws \OCP\Lock\LockedException
|
||||
*/
|
||||
public function changeLock($path, $type, ILockingProvider $provider);
|
||||
|
||||
/**
|
||||
* Get the contents of a directory with metadata
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,6 +279,15 @@ interface IStorage {
|
|||
*/
|
||||
public function free_space($path);
|
||||
|
||||
/**
|
||||
* search for occurrences of $query in file names
|
||||
*
|
||||
* @param string $query
|
||||
* @return array|bool
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public function search($query);
|
||||
|
||||
/**
|
||||
* see https://www.php.net/manual/en/function.touch.php
|
||||
* If the backend does not support the operation, false should be returned
|
||||
|
|
@ -404,6 +413,12 @@ interface IStorage {
|
|||
*/
|
||||
public function setAvailability($isAvailable);
|
||||
|
||||
/**
|
||||
* @since 12.0.0
|
||||
* @return mixed
|
||||
*/
|
||||
public function needsPartFile();
|
||||
|
||||
/**
|
||||
* @param string $path path for which to retrieve the owner
|
||||
* @since 9.0.0
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue