summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/DB/MySQLMigrator.php23
-rw-r--r--lib/private/Files/Mount/ObjectHomeMountProvider.php65
-rw-r--r--lib/private/Files/ObjectStore/Mapper.php52
-rw-r--r--lib/private/Updater.php9
4 files changed, 145 insertions, 4 deletions
diff --git a/lib/private/DB/MySQLMigrator.php b/lib/private/DB/MySQLMigrator.php
index 1b3f70a817d..7e1194865f8 100644
--- a/lib/private/DB/MySQLMigrator.php
+++ b/lib/private/DB/MySQLMigrator.php
@@ -24,6 +24,7 @@
namespace OC\DB;
use Doctrine\DBAL\Schema\Schema;
+use Doctrine\DBAL\Schema\Table;
class MySQLMigrator extends Migrator {
/**
@@ -48,4 +49,26 @@ class MySQLMigrator extends Migrator {
return $schemaDiff;
}
+
+ /**
+ * Speed up migration test by disabling autocommit and unique indexes check
+ *
+ * @param \Doctrine\DBAL\Schema\Table $table
+ * @throws \OC\DB\MigrationException
+ */
+ protected function checkTableMigrate(Table $table) {
+ $this->connection->exec('SET autocommit=0');
+ $this->connection->exec('SET unique_checks=0');
+
+ try {
+ parent::checkTableMigrate($table);
+ } catch (\Exception $e) {
+ $this->connection->exec('SET unique_checks=1');
+ $this->connection->exec('SET autocommit=1');
+ throw new MigrationException($table->getName(), $e->getMessage());
+ }
+ $this->connection->exec('SET unique_checks=1');
+ $this->connection->exec('SET autocommit=1');
+ }
+
}
diff --git a/lib/private/Files/Mount/ObjectHomeMountProvider.php b/lib/private/Files/Mount/ObjectHomeMountProvider.php
index c910cf6bd45..f82313879dc 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->getMultiBucketObjectStoreConfig($user);
+ if ($config === null) {
+ $config = $this->getSingleBucketObjectStoreConfig($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 getSingleBucketObjectStoreConfig(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,49 @@ 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 getMultiBucketObjectStoreConfig(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;
+
+ $bucket = $this->config->getUserValue($user->getUID(), 'homeobjectstore', 'bucket', null);
+
+ if ($bucket === null) {
+ /*
+ * 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();
+
+ $this->config->setUserValue($user->getUID(), 'homeobjectstore', 'bucket', $config['arguments']['bucket']);
+ } else {
+ $config['arguments']['bucket'] = $bucket;
+ }
+
+ // instantiate object store implementation
+ $config['arguments']['objectstore'] = new $config['class']($config['arguments']);
+
+ return $config;
}
}
diff --git a/lib/private/Files/ObjectStore/Mapper.php b/lib/private/Files/ObjectStore/Mapper.php
new file mode 100644
index 00000000000..f0004f1f966
--- /dev/null
+++ b/lib/private/Files/ObjectStore/Mapper.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * @author Roeland Jago Douma <rullzer@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+namespace OC\Files\ObjectStore;
+
+use OCP\IUser;
+
+/**
+ * Class Mapper
+ *
+ * @package OC\Files\ObjectStore
+ *
+ * Map a user to a bucket.
+ */
+class Mapper {
+ /** @var IUser */
+ private $user;
+
+ /**
+ * Mapper constructor.
+ *
+ * @param IUser $user
+ */
+ public function __construct(IUser $user) {
+ $this->user = $user;
+ }
+
+ /**
+ * @return string
+ */
+ public function getBucket() {
+ $hash = md5($this->user->getUID());
+ return substr($hash, 0, 3);
+ }
+} \ No newline at end of file
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index 608b62143d3..de813b1b607 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -217,8 +217,6 @@ class Updater extends BasicEmitter {
try {
Setup::updateHtaccess();
Setup::protectDataDirectory();
- // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
- Setup::installBackgroundJobs();
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
@@ -244,6 +242,13 @@ class Updater extends BasicEmitter {
if ($this->updateStepEnabled) {
$this->doCoreUpgrade();
+ try {
+ // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
+ Setup::installBackgroundJobs();
+ } catch (\Exception $e) {
+ throw new \Exception($e->getMessage());
+ }
+
// update all shipped apps
$disabledApps = $this->checkAppsRequirements();
$this->doAppUpgrade();