Skip to content

Commit 60fd2a7

Browse files
icewind1991backportbot[bot]
authored andcommitted
fix: improve check if external storage backend is local
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent d1d63db commit 60fd2a7

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

apps/files_external/lib/Controller/GlobalStoragesController.php

Lines changed: 4 additions & 1 deletion
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 OCA\Files_External\Settings\Admin;
1314
use OCP\AppFramework\Http;
@@ -37,6 +38,7 @@ public function __construct(
3738
IUserSession $userSession,
3839
IGroupManager $groupManager,
3940
IConfig $config,
41+
BackendService $backendService,
4042
) {
4143
parent::__construct(
4244
$appName,
@@ -46,7 +48,8 @@ public function __construct(
4648
$logger,
4749
$userSession,
4850
$groupManager,
49-
$config
51+
$config,
52+
$backendService
5053
);
5154
}
5255

apps/files_external/lib/Controller/StoragesController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
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\MountConfig;
1516
use OCA\Files_External\NotFoundException;
17+
use OCA\Files_External\Service\BackendService;
1618
use OCA\Files_External\Service\StoragesService;
1719
use OCP\AppFramework\Controller;
1820
use OCP\AppFramework\Http;
@@ -48,6 +50,7 @@ public function __construct(
4850
protected IUserSession $userSession,
4951
protected IGroupManager $groupManager,
5052
protected IConfig $config,
53+
private BackendService $backendService,
5154
) {
5255
parent::__construct($appName, $request);
5356
}
@@ -77,7 +80,7 @@ protected function createStorage(
7780
?int $priority = null,
7881
) {
7982
$canCreateNewLocalStorage = $this->config->getSystemValue('files_external_allow_create_new_local', true);
80-
if (!$canCreateNewLocalStorage && $backend === 'local') {
83+
if (!$canCreateNewLocalStorage && $this->backendService->getBackend($backend) instanceof Local) {
8184
return new DataResponse(
8285
[
8386
'message' => $this->l10n->t('Forbidden to manage local mounts')

apps/files_external/lib/Controller/UserGlobalStoragesController.php

Lines changed: 4 additions & 1 deletion
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;
@@ -50,6 +51,7 @@ public function __construct(
5051
IUserSession $userSession,
5152
IGroupManager $groupManager,
5253
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: 4 additions & 1 deletion
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;
@@ -40,6 +41,7 @@ public function __construct(
4041
IUserSession $userSession,
4142
IGroupManager $groupManager,
4243
IConfig $config,
44+
BackendService $backendService,
4345
) {
4446
parent::__construct(
4547
$appName,
@@ -49,7 +51,8 @@ public function __construct(
4951
$logger,
5052
$userSession,
5153
$groupManager,
52-
$config
54+
$config,
55+
$backendService,
5356
);
5457
}
5558

0 commit comments

Comments
 (0)