diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-12 14:22:27 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-19 10:05:11 +0100 |
commit | a6a69ef1dfe1545e1362953803219ed6f28f71a5 (patch) | |
tree | 9c3c76b5c66f1fc83d843699c1878a825c18e52d /apps/files_external/service/storagesservice.php | |
parent | 37beb58c6f395523d8e2934870c5f52a8c6f6df0 (diff) | |
download | nextcloud-server-a6a69ef1dfe1545e1362953803219ed6f28f71a5.tar.gz nextcloud-server-a6a69ef1dfe1545e1362953803219ed6f28f71a5.zip |
Introduce UserGlobalStoragesService
UserGlobalStoragesService reads the global storage configuration,
cherry-picking storages applicable to a user. Writing storages through
this service is forbidden, on punishment of throwing an exception.
Storage IDs may also be config hashes when retrieved from this service,
as it is unable to update the storages with real IDs.
As UserGlobalStoragesService and UserStoragesService share a bit of code
relating to users, that has been split into UserTrait. UserTrait also
allows for the user set to be overridden, rather than using the user
from IUserSession.
Config\ConfigAdapter has been reworked to use UserStoragesService and
UserGlobalStoragesService instead of
OC_Mount_Config::getAbsoluteMountPoints(), further reducing dependance
on that horrible static class.
Diffstat (limited to 'apps/files_external/service/storagesservice.php')
-rw-r--r-- | apps/files_external/service/storagesservice.php | 38 |
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 |