fix: improve check if external storage backend is local

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2026-05-04 18:35:24 +02:00
parent d1993bfd6e
commit 91eee32499
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB
4 changed files with 20 additions and 8 deletions

View file

@ -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 OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
@ -43,7 +44,8 @@ class GlobalStoragesController extends StoragesController {
LoggerInterface $logger,
IUserSession $userSession,
IGroupManager $groupManager,
IConfig $config
IConfig $config,
BackendService $backendService
) {
parent::__construct(
$AppName,
@ -53,7 +55,8 @@ class GlobalStoragesController extends StoragesController {
$logger,
$userSession,
$groupManager,
$config
$config,
$backendService
);
}

View file

@ -9,9 +9,11 @@ namespace OCA\Files_External\Controller;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\Backend\Local;
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\StoragesService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
@ -46,7 +48,8 @@ abstract class StoragesController extends Controller {
protected LoggerInterface $logger,
protected IUserSession $userSession,
protected IGroupManager $groupManager,
protected IConfig $config
protected IConfig $config,
private BackendService $backendService
) {
parent::__construct($AppName, $request);
}
@ -76,7 +79,7 @@ abstract class StoragesController extends Controller {
$priority = null
) {
$canCreateNewLocalStorage = $this->config->getSystemValue('files_external_allow_create_new_local', true);
if (!$canCreateNewLocalStorage && $backend === 'local') {
if (!$canCreateNewLocalStorage && $this->backendService->getBackend($backend) instanceof Local) {
return new DataResponse(
[
'message' => $this->l10n->t('Forbidden to manage local mounts')

View file

@ -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;
@ -49,7 +50,8 @@ class UserGlobalStoragesController extends StoragesController {
LoggerInterface $logger,
IUserSession $userSession,
IGroupManager $groupManager,
IConfig $config
IConfig $config,
BackendService $backendService
) {
parent::__construct(
$AppName,
@ -59,7 +61,8 @@ class UserGlobalStoragesController extends StoragesController {
$logger,
$userSession,
$groupManager,
$config
$config,
$backendService,
);
}

View file

@ -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;
@ -46,7 +47,8 @@ class UserStoragesController extends StoragesController {
LoggerInterface $logger,
IUserSession $userSession,
IGroupManager $groupManager,
IConfig $config
IConfig $config,
BackendService $backendService
) {
parent::__construct(
$AppName,
@ -56,7 +58,8 @@ class UserStoragesController extends StoragesController {
$logger,
$userSession,
$groupManager,
$config
$config,
$backendService,
);
}