Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/backup.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2021-12-24 15:22:28 +0300
committerMaxence Lange <maxence@artificial-owl.com>2021-12-24 15:22:28 +0300
commit235cd860f98046a741ff1ac33c1770c7ee3ea972 (patch)
tree89ad4cb8e8eef555e232474cef160180517195fa /lib
parent68c0cb09a87bd3e274ae729e81166910ae529230 (diff)
+prepareStorageConfig
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Service/ExternalFolderService.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/Service/ExternalFolderService.php b/lib/Service/ExternalFolderService.php
index 4037341..debc585 100644
--- a/lib/Service/ExternalFolderService.php
+++ b/lib/Service/ExternalFolderService.php
@@ -58,7 +58,9 @@ use OCA\Backup\Model\RestoringHealth;
use OCA\Backup\Model\RestoringPoint;
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\Service\GlobalStoragesService;
+use OCP\AppFramework\QueryException;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\GenericFileException;
use OCP\Files\InvalidPathException;
@@ -816,6 +818,12 @@ class ExternalFolderService {
$externals = $this->getAll();
foreach ($this->globalStoragesService->getAllStorages() as $globalStorage) {
+ try {
+ $this->prepareStorageConfig($globalStorage);
+ } catch (Exception $e) {
+ $this->e($e);
+ continue;
+ }
$storage = $this->constructStorage($globalStorage);
$storageId = Storage::getNumericStorageId($storage->getId());
@@ -865,6 +873,34 @@ class ExternalFolderService {
/**
+ * Process storage ready for mounting
+ * based on apps/files_external/lib/Config/ConfigAdapter.php
+ *
+ * @param StorageConfig $storage
+ *
+ * @throws InsufficientDataForMeaningfulAnswerException
+ * @throws StorageNotAvailableException
+ * @throws QueryException
+ */
+ private function prepareStorageConfig(StorageConfig &$storage) {
+ foreach ($storage->getBackendOptions() as $option => $value) {
+ $storage->setBackendOption($option, MountConfig::substitutePlaceholdersInConfig($value));
+ }
+
+ $objectStore = $storage->getBackendOption('objectstore');
+ if ($objectStore) {
+ $objectClass = $objectStore['class'];
+ if (!is_subclass_of($objectClass, '\OCP\Files\ObjectStore\IObjectStore')) {
+ throw new \InvalidArgumentException('Invalid object store');
+ }
+ $storage->setBackendOption('objectstore', new $objectClass($objectStore));
+ }
+
+ $storage->getAuthMechanism()->manipulateStorageConfig($storage, $user);
+ $storage->getBackend()->manipulateStorageConfig($storage, $user);
+ }
+
+ /**
* Construct the storage implementation
* based on apps/files_external/lib/Config/ConfigAdapter.php
*