diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-05-22 20:44:06 +0200 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-05-23 20:42:08 +0200 |
commit | 5e2316d05d954ec9cb9a3d284007c3d329550395 (patch) | |
tree | 798536d78981ccd702c8f6c7fead825bd2259bad /lib/private/Files/Mount | |
parent | aa56d42fa8aafbed96eecfb898fa5c02340493a7 (diff) | |
download | nextcloud-server-5e2316d05d954ec9cb9a3d284007c3d329550395.tar.gz nextcloud-server-5e2316d05d954ec9cb9a3d284007c3d329550395.zip |
Allow multibucket in objectstore
Diffstat (limited to 'lib/private/Files/Mount')
-rw-r--r-- | lib/private/Files/Mount/ObjectHomeMountProvider.php | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/lib/private/Files/Mount/ObjectHomeMountProvider.php b/lib/private/Files/Mount/ObjectHomeMountProvider.php index c910cf6bd45..aa6a443971f 100644 --- a/lib/private/Files/Mount/ObjectHomeMountProvider.php +++ b/lib/private/Files/Mount/ObjectHomeMountProvider.php @@ -52,9 +52,27 @@ class ObjectHomeMountProvider implements IHomeMountProvider { * @return \OCP\Files\Mount\IMountPoint[] */ public function getHomeMountForUser(IUser $user, IStorageFactory $loader) { + + $config = $this->multiBucketObjectStore($user); + if ($config === null) { + $config = $this->singleBucketObjectStore($user); + } + + if ($config === null) { + return null; + } + + return new MountPoint('\OC\Files\ObjectStore\HomeObjectStoreStorage', '/' . $user->getUID(), $config['arguments'], $loader); + } + + /** + * @param IUser $user + * @return array|null + */ + private function singleBucketObjectStore(IUser $user) { $config = $this->config->getSystemValue('objectstore'); if (!is_array($config)) { - return null; //fall back to local home provider + return null; } // sanity checks @@ -68,6 +86,41 @@ class ObjectHomeMountProvider implements IHomeMountProvider { // instantiate object store implementation $config['arguments']['objectstore'] = new $config['class']($config['arguments']); - return new MountPoint('\OC\Files\ObjectStore\HomeObjectStoreStorage', '/' . $user->getUID(), $config['arguments'], $loader); + return $config; + } + + /** + * @param IUser $user + * @return array|null + */ + private function multiBucketObjectStore(IUser $user) { + $config = $this->config->getSystemValue('objectstore_multibucket'); + if (!is_array($config)) { + return null; + } + + // sanity checks + if (empty($config['class'])) { + \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR); + } + if (!isset($config['arguments'])) { + $config['arguments'] = []; + } + $config['arguments']['user'] = $user; + + /* + * Use any provided bucket argument as prefix + * and add the mapping from username => bucket + */ + if (!isset($config['arguments']['bucket'])) { + $config['arguments']['bucket'] = ''; + } + $mapper = new \OC\Files\ObjectStore\Mapper($user); + $config['arguments']['bucket'] .= $mapper->getBucket(); + + // instantiate object store implementation + $config['arguments']['objectstore'] = new $config['class']($config['arguments']); + + return $config; } } |