summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-05-10 16:50:19 -0500
committerGitHub <noreply@github.com>2017-05-10 16:50:19 -0500
commit1c2ccd220611a3c269c8122dcab8a3a6251053ef (patch)
treed0dc408722ee3b402d320100ff3d04ecf854dba5
parentaffa8d07cab3617e7f2101e3b81a212fa86ab832 (diff)
parentd73c8d09818787afd3d046bdd888a0f432131f8a (diff)
downloadnextcloud-server-1c2ccd220611a3c269c8122dcab8a3a6251053ef.tar.gz
nextcloud-server-1c2ccd220611a3c269c8122dcab8a3a6251053ef.zip
Merge pull request #4798 from nextcloud/multibucket-root-fs
Setup root FS for multibucket object storage
-rw-r--r--lib/private/Server.php2
-rw-r--r--lib/private/legacy/util.php47
2 files changed, 47 insertions, 2 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 07e449ee4a9..9731bd294e8 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -884,7 +884,7 @@ class Server extends ServerContainer implements IServerContainer {
$c->getConfig(),
$c->getThemingDefaults(),
\OC::$SERVERROOT,
- $cacheFactory->createLocal('SCSS')
+ $cacheFactory->create('SCSS')
);
});
$this->registerService(EventDispatcher::class, function () {
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index a1e6f2fe702..ac6c47b189c 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -120,6 +120,46 @@ class OC_Util {
}
/**
+ * mounting an object storage as the root fs will in essence remove the
+ * necessity of a data folder being present.
+ *
+ * @param array $config containing 'class' and optional 'arguments'
+ */
+ private static function initObjectStoreMultibucketRootFS($config) {
+ // check misconfiguration
+ if (empty($config['class'])) {
+ \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR);
+ }
+ if (!isset($config['arguments'])) {
+ $config['arguments'] = array();
+ }
+
+ // instantiate object store implementation
+ $name = $config['class'];
+ if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) {
+ $segments = explode('\\', $name);
+ OC_App::loadApp(strtolower($segments[1]));
+ }
+
+ if (!isset($config['arguments']['bucket'])) {
+ $config['arguments']['bucket'] = '';
+ }
+ // put the root FS always in first bucket for multibucket configuration
+ $config['arguments']['bucket'] .= '0';
+
+ $config['arguments']['objectstore'] = new $config['class']($config['arguments']);
+ // mount with plain / root object store implementation
+ $config['class'] = '\OC\Files\ObjectStore\ObjectStoreStorage';
+
+ // mount object storage as root
+ \OC\Files\Filesystem::initMountManager();
+ if (!self::$rootMounted) {
+ \OC\Files\Filesystem::mount($config['class'], $config['arguments'], '/');
+ self::$rootMounted = true;
+ }
+ }
+
+ /**
* Can be set up
*
* @param string $user
@@ -215,7 +255,12 @@ class OC_Util {
//check if we are using an object storage
$objectStore = \OC::$server->getSystemConfig()->getValue('objectstore', null);
- if (isset($objectStore)) {
+ $objectStoreMultibucket = \OC::$server->getSystemConfig()->getValue('objectstore_multibucket', null);
+
+ // use the same order as in ObjectHomeMountProvider
+ if (isset($objectStoreMultibucket)) {
+ self::initObjectStoreMultibucketRootFS($objectStoreMultibucket);
+ } elseif (isset($objectStore)) {
self::initObjectStoreRootFS($objectStore);
} else {
self::initLocalStorageRootFS();