summaryrefslogtreecommitdiffstats
path: root/apps/files_external/service/storagesservice.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/service/storagesservice.php')
-rw-r--r--apps/files_external/service/storagesservice.php38
1 files changed, 29 insertions, 9 deletions
diff --git a/apps/files_external/service/storagesservice.php b/apps/files_external/service/storagesservice.php
index 5f11d9ace68..d3bde0ae96c 100644
--- a/apps/files_external/service/storagesservice.php
+++ b/apps/files_external/service/storagesservice.php
@@ -56,6 +56,16 @@ abstract class StoragesService {
}
/**
+ * Write legacy config data
+ *
+ * @param array $mountPoints
+ */
+ protected function writeLegacyConfig(array $mountPoints) {
+ // write global config
+ \OC_Mount_Config::writeData(null, $mountPoints);
+ }
+
+ /**
* Copy legacy storage options into the given storage config object.
*
* @param StorageConfig $storageConfig storage config to populate
@@ -202,21 +212,31 @@ abstract class StoragesService {
// process storages with config hash, they must get a real id
if (!empty($storagesWithConfigHash)) {
- $nextId = $this->generateNextId($storages);
- foreach ($storagesWithConfigHash as $storage) {
- $storage->setId($nextId);
- $storages[$nextId] = $storage;
- $nextId++;
- }
-
- // re-save the config with the generated ids
- $this->writeConfig($storages);
+ $this->setRealStorageIds($storages, $storagesWithConfigHash);
}
return $storages;
}
/**
+ * Replace config hash ID with real IDs, for migrating legacy storages
+ *
+ * @param StorageConfig[] $storages Storages with real IDs
+ * @param StorageConfig[] $storagesWithConfigHash Storages with config hash IDs
+ */
+ protected function setRealStorageIds(array &$storages, array $storagesWithConfigHash) {
+ $nextId = $this->generateNextId($storages);
+ foreach ($storagesWithConfigHash as $storage) {
+ $storage->setId($nextId);
+ $storages[$nextId] = $storage;
+ $nextId++;
+ }
+
+ // re-save the config with the generated ids
+ $this->writeConfig($storages);
+ }
+
+ /**
* Add mount point into the messy mount point structure
*
* @param array $mountPoints messy array of mount points