Skip to content

Commit ddc41d6

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 45f7e26 commit ddc41d6

4 files changed

Lines changed: 26 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
@@ -28,6 +28,7 @@
2828
namespace OCA\Files_External\Controller;
2929

3030
use OCA\Files_External\NotFoundException;
31+
use OCA\Files_External\Service\BackendService;
3132
use OCA\Files_External\Service\GlobalStoragesService;
3233
use OCP\AppFramework\Http;
3334
use OCP\AppFramework\Http\DataResponse;
@@ -62,7 +63,8 @@ public function __construct(
6263
ILogger $logger,
6364
IUserSession $userSession,
6465
IGroupManager $groupManager,
65-
IConfig $config
66+
IConfig $config,
67+
BackendService $backendService
6668
) {
6769
parent::__construct(
6870
$AppName,
@@ -72,7 +74,8 @@ public function __construct(
7274
$logger,
7375
$userSession,
7476
$groupManager,
75-
$config
77+
$config,
78+
$backendService
7679
);
7780
}
7881

apps/files_external/lib/Controller/StoragesController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
use OCA\Files_External\Lib\Auth\AuthMechanism;
3232
use OCA\Files_External\Lib\Backend\Backend;
3333
use OCA\Files_External\Lib\DefinitionParameter;
34+
use OCA\Files_External\Lib\Backend\Local;
3435
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
3536
use OCA\Files_External\Lib\StorageConfig;
3637
use OCA\Files_External\NotFoundException;
38+
use OCA\Files_External\Service\BackendService;
3739
use OCA\Files_External\Service\StoragesService;
3840
use OCP\AppFramework\Controller;
3941
use OCP\AppFramework\Http;
@@ -85,6 +87,11 @@ abstract class StoragesController extends Controller {
8587
*/
8688
protected $config;
8789

90+
/**
91+
* @var BackendService
92+
*/
93+
protected $backendService;
94+
8895
/**
8996
* Creates a new storages controller.
9097
*
@@ -102,7 +109,8 @@ public function __construct(
102109
ILogger $logger,
103110
IUserSession $userSession,
104111
IGroupManager $groupManager,
105-
IConfig $config
112+
IConfig $config,
113+
BackendService $backendService
106114
) {
107115
parent::__construct($AppName, $request);
108116
$this->l10n = $l10n;
@@ -111,6 +119,7 @@ public function __construct(
111119
$this->userSession = $userSession;
112120
$this->groupManager = $groupManager;
113121
$this->config = $config;
122+
$this->backendService = $backendService;
114123
}
115124

116125
/**
@@ -138,7 +147,7 @@ protected function createStorage(
138147
$priority = null
139148
) {
140149
$canCreateNewLocalStorage = $this->config->getSystemValue('files_external_allow_create_new_local', true);
141-
if (!$canCreateNewLocalStorage && $backend === 'local') {
150+
if (!$canCreateNewLocalStorage && $this->backendService->getBackend($backend) instanceof Local) {
142151
return new DataResponse(
143152
[
144153
'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
@@ -33,6 +33,7 @@
3333
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
3434
use OCA\Files_External\Lib\StorageConfig;
3535
use OCA\Files_External\NotFoundException;
36+
use OCA\Files_External\Service\BackendService;
3637
use OCA\Files_External\Service\UserGlobalStoragesService;
3738
use OCP\AppFramework\Http;
3839
use OCP\AppFramework\Http\DataResponse;
@@ -66,7 +67,8 @@ public function __construct(
6667
ILogger $logger,
6768
IUserSession $userSession,
6869
IGroupManager $groupManager,
69-
IConfig $config
70+
IConfig $config,
71+
BackendService $backendService
7072
) {
7173
parent::__construct(
7274
$AppName,
@@ -76,7 +78,8 @@ public function __construct(
7678
$logger,
7779
$userSession,
7880
$groupManager,
79-
$config
81+
$config,
82+
$backendService,
8083
);
8184
}
8285

apps/files_external/lib/Controller/UserStoragesController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use OCA\Files_External\Lib\Backend\Backend;
3333
use OCA\Files_External\Lib\StorageConfig;
3434
use OCA\Files_External\NotFoundException;
35+
use OCA\Files_External\Service\BackendService;
3536
use OCA\Files_External\Service\UserStoragesService;
3637
use OCP\AppFramework\Http;
3738
use OCP\AppFramework\Http\DataResponse;
@@ -65,7 +66,8 @@ public function __construct(
6566
ILogger $logger,
6667
IUserSession $userSession,
6768
IGroupManager $groupManager,
68-
IConfig $config
69+
IConfig $config,
70+
BackendService $backendService
6971
) {
7072
parent::__construct(
7173
$AppName,
@@ -75,7 +77,8 @@ public function __construct(
7577
$logger,
7678
$userSession,
7779
$groupManager,
78-
$config
80+
$config,
81+
$backendService,
7982
);
8083
}
8184

0 commit comments

Comments
 (0)