diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-01-27 13:35:31 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-01-27 13:44:05 +0100 |
commit | 37645153653b0717a8d354aea6d0c13a3a9b7d31 (patch) | |
tree | cfc4921947c028c683d411118a00040589d4c426 /apps/files_external/lib | |
parent | c4b02176dcf7299cf6d9d1bc8db66db79d14e2e8 (diff) | |
download | nextcloud-server-37645153653b0717a8d354aea6d0c13a3a9b7d31.tar.gz nextcloud-server-37645153653b0717a8d354aea6d0c13a3a9b7d31.zip |
Allow saving incomplete external storage config
This is needed for Dropbox and others that need a token.
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r-- | apps/files_external/lib/config.php | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 823c0bcbfc1..ddfab439879 100644 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -882,6 +882,11 @@ class OC_Mount_Config { return hash('md5', $data); } + /** + * Add storage id to the storage configurations that did not have any. + * + * @param string $user user for which to process storage configs + */ private static function addStorageIdToConfig($user) { $config = self::readData($user); @@ -899,13 +904,35 @@ class OC_Mount_Config { } } + /** + * Get storage id from the numeric storage id and set + * it into the given options argument. Only do this + * if there was no storage id set yet. + * + * This might also fail if a storage wasn't fully configured yet + * and couldn't be mounted, in which case this will simply return false. + * + * @param array $options storage options + * + * @return bool true if the storage id was added, false otherwise + */ private static function addStorageId(&$options) { if (isset($options['storage_id'])) { return false; } + $class = $options['class']; - /** @var \OC\Files\Storage\Storage $storage */ - $storage = new $class($options['options']); + try { + /** @var \OC\Files\Storage\Storage $storage */ + $storage = new $class($options['options']); + // TODO: introduce StorageConfigException + } catch (\Exception $e) { + // storage might not be fully configured yet (ex: Dropbox) + // note that storage instances aren't supposed to open any connections + // in the constructor, so this exception is likely to be a config exception + return false; + } + $options['storage_id'] = $storage->getCache()->getNumericStorageId(); return true; } |