Skip to content

Commit 9e639fe

Browse files
committed
fix: improve check if external storage backend is local
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 211840a commit 9e639fe

4 files changed

Lines changed: 20 additions & 8 deletions

File tree

apps/files_external/lib/Controller/GlobalStoragesController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace OCA\Files_External\Controller;
99

1010
use OCA\Files_External\NotFoundException;
11+
use OCA\Files_External\Service\BackendService;
1112
use OCA\Files_External\Service\GlobalStoragesService;
1213
use OCP\AppFramework\Http;
1314
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
@@ -43,7 +44,8 @@ public function __construct(
4344
LoggerInterface $logger,
4445
IUserSession $userSession,
4546
IGroupManager $groupManager,
46-
IConfig $config
47+
IConfig $config,
48+
BackendService $backendService
4749
) {
4850
parent::__construct(
4951
$AppName,
@@ -53,7 +55,8 @@ public function __construct(
5355
$logger,
5456
$userSession,
5557
$groupManager,
56-
$config
58+
$config,
59+
$backendService
5760
);
5861
}
5962

apps/files_external/lib/Controller/StoragesController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
use OCA\Files_External\Lib\Auth\AuthMechanism;
1111
use OCA\Files_External\Lib\Backend\Backend;
12+
use OCA\Files_External\Lib\Backend\Local;
1213
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
1314
use OCA\Files_External\Lib\StorageConfig;
1415
use OCA\Files_External\NotFoundException;
16+
use OCA\Files_External\Service\BackendService;
1517
use OCA\Files_External\Service\StoragesService;
1618
use OCP\AppFramework\Controller;
1719
use OCP\AppFramework\Http;
@@ -46,7 +48,8 @@ public function __construct(
4648
protected LoggerInterface $logger,
4749
protected IUserSession $userSession,
4850
protected IGroupManager $groupManager,
49-
protected IConfig $config
51+
protected IConfig $config,
52+
private BackendService $backendService
5053
) {
5154
parent::__construct($AppName, $request);
5255
}
@@ -76,7 +79,7 @@ protected function createStorage(
7679
$priority = null
7780
) {
7881
$canCreateNewLocalStorage = $this->config->getSystemValue('files_external_allow_create_new_local', true);
79-
if (!$canCreateNewLocalStorage && $backend === 'local') {
82+
if (!$canCreateNewLocalStorage && $this->backendService->getBackend($backend) instanceof Local) {
8083
return new DataResponse(
8184
[
8285
'message' => $this->l10n->t('Forbidden to manage local mounts')

apps/files_external/lib/Controller/UserGlobalStoragesController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
1515
use OCA\Files_External\Lib\StorageConfig;
1616
use OCA\Files_External\NotFoundException;
17+
use OCA\Files_External\Service\BackendService;
1718
use OCA\Files_External\Service\UserGlobalStoragesService;
1819
use OCP\AppFramework\Http;
1920
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
@@ -49,7 +50,8 @@ public function __construct(
4950
LoggerInterface $logger,
5051
IUserSession $userSession,
5152
IGroupManager $groupManager,
52-
IConfig $config
53+
IConfig $config,
54+
BackendService $backendService
5355
) {
5456
parent::__construct(
5557
$AppName,
@@ -59,7 +61,8 @@ public function __construct(
5961
$logger,
6062
$userSession,
6163
$groupManager,
62-
$config
64+
$config,
65+
$backendService,
6366
);
6467
}
6568

apps/files_external/lib/Controller/UserStoragesController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OCA\Files_External\Lib\Backend\Backend;
1212
use OCA\Files_External\Lib\StorageConfig;
1313
use OCA\Files_External\NotFoundException;
14+
use OCA\Files_External\Service\BackendService;
1415
use OCA\Files_External\Service\UserStoragesService;
1516
use OCP\AppFramework\Http;
1617
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
@@ -46,7 +47,8 @@ public function __construct(
4647
LoggerInterface $logger,
4748
IUserSession $userSession,
4849
IGroupManager $groupManager,
49-
IConfig $config
50+
IConfig $config,
51+
BackendService $backendService
5052
) {
5153
parent::__construct(
5254
$AppName,
@@ -56,7 +58,8 @@ public function __construct(
5658
$logger,
5759
$userSession,
5860
$groupManager,
59-
$config
61+
$config,
62+
$backendService,
6063
);
6164
}
6265

0 commit comments

Comments
 (0)