mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
fix(files_external): Migrate call to now-deprecated static methods
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
d990e72fa8
commit
7439b3db64
12 changed files with 38 additions and 23 deletions
|
|
@ -10,8 +10,8 @@ namespace OCA\Files_External\Command;
|
|||
use OC\Core\Command\Base;
|
||||
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
use OCA\Files_External\MountConfig;
|
||||
use OCA\Files_External\NotFoundException;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCA\Files_External\Service\GlobalStoragesService;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\Files\StorageNotAvailableException;
|
||||
|
|
@ -23,6 +23,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
class Verify extends Base {
|
||||
public function __construct(
|
||||
protected GlobalStoragesService $globalService,
|
||||
protected BackendService $backendService,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
|
@ -96,7 +97,7 @@ class Verify extends Base {
|
|||
$backend = $storage->getBackend();
|
||||
// update status (can be time-consuming)
|
||||
$storage->setStatus(
|
||||
MountConfig::getBackendStatus(
|
||||
$this->backendService->getBackendStatus(
|
||||
$backend->getStorageClass(),
|
||||
$storage->getBackendOptions(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use OC\Files\Storage\Wrapper\Availability;
|
|||
use OC\Files\Storage\Wrapper\KnownMtime;
|
||||
use OCA\Files_External\Lib\PersonalMount;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
use OCA\Files_External\MountConfig;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCA\Files_External\Service\UserGlobalStoragesService;
|
||||
use OCA\Files_External\Service\UserStoragesService;
|
||||
use OCP\Files\Config\IAuthoritativeMountProvider;
|
||||
|
|
@ -39,6 +39,7 @@ class ConfigAdapter implements IMountProvider, IAuthoritativeMountProvider, IPar
|
|||
public function __construct(
|
||||
private UserStoragesService $userStoragesService,
|
||||
private UserGlobalStoragesService $userGlobalStoragesService,
|
||||
private BackendService $backendService,
|
||||
private ClockInterface $clock,
|
||||
) {
|
||||
}
|
||||
|
|
@ -63,7 +64,7 @@ class ConfigAdapter implements IMountProvider, IAuthoritativeMountProvider, IPar
|
|||
*/
|
||||
private function prepareStorageConfig(StorageConfig &$storage, IUser $user): void {
|
||||
foreach ($storage->getBackendOptions() as $option => $value) {
|
||||
$storage->setBackendOption($option, MountConfig::substitutePlaceholdersInConfig($value, $user->getUID()));
|
||||
$storage->setBackendOption($option, $this->backendService->applyConfigHandlers($value, $user->getUID()));
|
||||
}
|
||||
|
||||
$objectStore = $storage->getBackendOption('objectstore');
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
namespace OCA\Files_External\Controller;
|
||||
|
||||
use OCA\Files_External\NotFoundException;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCA\Files_External\Service\GlobalStoragesService;
|
||||
use OCA\Files_External\Settings\Admin;
|
||||
use OCP\AppFramework\Http;
|
||||
|
|
@ -37,6 +38,7 @@ class GlobalStoragesController extends StoragesController {
|
|||
IUserSession $userSession,
|
||||
IGroupManager $groupManager,
|
||||
IConfig $config,
|
||||
BackendService $backendService,
|
||||
) {
|
||||
parent::__construct(
|
||||
$appName,
|
||||
|
|
@ -46,7 +48,8 @@ class GlobalStoragesController extends StoragesController {
|
|||
$logger,
|
||||
$userSession,
|
||||
$groupManager,
|
||||
$config
|
||||
$config,
|
||||
$backendService,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ use OCA\Files_External\Lib\Auth\AuthMechanism;
|
|||
use OCA\Files_External\Lib\Backend\Backend;
|
||||
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
use OCA\Files_External\MountConfig;
|
||||
use OCA\Files_External\NotFoundException;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCA\Files_External\Service\StoragesService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
|
|
@ -48,6 +48,7 @@ abstract class StoragesController extends Controller {
|
|||
protected IUserSession $userSession,
|
||||
protected IGroupManager $groupManager,
|
||||
protected IConfig $config,
|
||||
protected BackendService $backendService,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
}
|
||||
|
|
@ -222,7 +223,7 @@ abstract class StoragesController extends Controller {
|
|||
$backend = $storage->getBackend();
|
||||
// update status (can be time-consuming)
|
||||
$storage->setStatus(
|
||||
MountConfig::getBackendStatus(
|
||||
$this->backendService->getBackendStatus(
|
||||
$backend->getStorageClass(),
|
||||
$storage->getBackendOptions(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use OCA\Files_External\Lib\Backend\Backend;
|
|||
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
use OCA\Files_External\NotFoundException;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCA\Files_External\Service\UserGlobalStoragesService;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
|
|
@ -50,6 +51,7 @@ class UserGlobalStoragesController extends StoragesController {
|
|||
IUserSession $userSession,
|
||||
IGroupManager $groupManager,
|
||||
IConfig $config,
|
||||
BackendService $backendService,
|
||||
) {
|
||||
parent::__construct(
|
||||
$appName,
|
||||
|
|
@ -59,7 +61,8 @@ class UserGlobalStoragesController extends StoragesController {
|
|||
$logger,
|
||||
$userSession,
|
||||
$groupManager,
|
||||
$config
|
||||
$config,
|
||||
$backendService,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use OCA\Files_External\Lib\Auth\AuthMechanism;
|
|||
use OCA\Files_External\Lib\Backend\Backend;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
use OCA\Files_External\NotFoundException;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCA\Files_External\Service\UserStoragesService;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
|
|
@ -40,6 +41,7 @@ class UserStoragesController extends StoragesController {
|
|||
IUserSession $userSession,
|
||||
IGroupManager $groupManager,
|
||||
IConfig $config,
|
||||
BackendService $backendService,
|
||||
) {
|
||||
parent::__construct(
|
||||
$appName,
|
||||
|
|
@ -49,7 +51,8 @@ class UserStoragesController extends StoragesController {
|
|||
$logger,
|
||||
$userSession,
|
||||
$groupManager,
|
||||
$config
|
||||
$config,
|
||||
$backendService,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use OCA\Files_External\Lib\Config\IAuthMechanismProvider;
|
|||
use OCA\Files_External\Lib\Config\IBackendProvider;
|
||||
use OCP\EventDispatcher\GenericEvent;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Files\StorageNotAvailableException;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\Server;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
|
|
|
|||
|
|
@ -11,13 +11,6 @@ namespace OCA\Files_External\Service;
|
|||
class ImportLegacyStoragesService extends LegacyStoragesService {
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* @param BackendService $backendService
|
||||
*/
|
||||
public function __construct(BackendService $backendService) {
|
||||
$this->backendService = $backendService;
|
||||
}
|
||||
|
||||
public function setData($data) {
|
||||
$this->data = $data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ use Psr\Log\LoggerInterface;
|
|||
* Read mount config from legacy mount.json
|
||||
*/
|
||||
abstract class LegacyStoragesService {
|
||||
/** @var BackendService */
|
||||
protected $backendService;
|
||||
|
||||
public function __construct(
|
||||
protected BackendService $backendService,
|
||||
protected EncryptionService $encryptionService,
|
||||
) {
|
||||
}
|
||||
/**
|
||||
* Read legacy config data
|
||||
*
|
||||
|
|
@ -132,7 +134,7 @@ abstract class LegacyStoragesService {
|
|||
$relativeMountPath = rtrim($parts[2], '/');
|
||||
// note: we cannot do this after the loop because the decrypted config
|
||||
// options might be needed for the config hash
|
||||
$storageOptions['options'] = MountConfig::decryptPasswords($storageOptions['options']);
|
||||
$storageOptions['options'] = $this->encryptionService->decryptPasswords($storageOptions['options']);
|
||||
if (!isset($storageOptions['backend'])) {
|
||||
$storageOptions['backend'] = $storageOptions['class']; // legacy compat
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,12 @@ class ConfigAdapterTest extends TestCase {
|
|||
|
||||
$this->userStoragesService = Server::get(UserStoragesService::class);
|
||||
$this->userGlobalStoragesService = Server::get(UserGlobalStoragesService::class);
|
||||
$this->adapter = new ConfigAdapter($this->userStoragesService, $this->userGlobalStoragesService, $this->createMock(ClockInterface::class));
|
||||
$this->adapter = new ConfigAdapter(
|
||||
$this->userStoragesService,
|
||||
$this->userGlobalStoragesService,
|
||||
$this->createMock(BackendService::class),
|
||||
$this->createMock(ClockInterface::class),
|
||||
);
|
||||
|
||||
$this->user = $this->createMock(IUser::class);
|
||||
$this->user->method('getUID')->willReturn('user1');
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ class GlobalStoragesControllerTest extends StoragesControllerTestCase {
|
|||
$this->createMock(LoggerInterface::class),
|
||||
$session,
|
||||
$this->createMock(IGroupManager::class),
|
||||
$config
|
||||
$config,
|
||||
$this->createMock(BackendService::class),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ class UserStoragesControllerTest extends StoragesControllerTestCase {
|
|||
$this->createMock(LoggerInterface::class),
|
||||
$session,
|
||||
$this->createMock(IGroupManager::class),
|
||||
$config
|
||||
$config,
|
||||
$this->createMock(BackendService::class),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue