summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-11-02 22:05:57 +0100
committerGitHub <noreply@github.com>2016-11-02 22:05:57 +0100
commitc1feae1684934bb52b1edaa67d33d01b377b875a (patch)
tree1a278d6b1f0a0204d6ac1b4cd17034c4bbb6d8d6 /lib
parentb4cf559707b48bca6d52194dec87d84a5597c317 (diff)
parent049bcae29ebf6106b33dd44f3be30e2a8486cd98 (diff)
downloadnextcloud-server-c1feae1684934bb52b1edaa67d33d01b377b875a.tar.gz
nextcloud-server-c1feae1684934bb52b1edaa67d33d01b377b875a.zip
Merge pull request #1981 from nextcloud/multibucket-num-buckets
Allow setting a maximun number of buckets for multibucket
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Mount/ObjectHomeMountProvider.php3
-rw-r--r--lib/private/Files/ObjectStore/Mapper.php8
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/private/Files/Mount/ObjectHomeMountProvider.php b/lib/private/Files/Mount/ObjectHomeMountProvider.php
index c1eea34a72e..87878562a42 100644
--- a/lib/private/Files/Mount/ObjectHomeMountProvider.php
+++ b/lib/private/Files/Mount/ObjectHomeMountProvider.php
@@ -121,7 +121,8 @@ class ObjectHomeMountProvider implements IHomeMountProvider {
$config['arguments']['bucket'] = '';
}
$mapper = new \OC\Files\ObjectStore\Mapper($user);
- $config['arguments']['bucket'] .= $mapper->getBucket();
+ $numBuckets = isset($config['arguments']['num_buckets']) ? $config['arguments']['num_buckets'] : 64;
+ $config['arguments']['bucket'] .= $mapper->getBucket($numBuckets);
$this->config->setUserValue($user->getUID(), 'homeobjectstore', 'bucket', $config['arguments']['bucket']);
} else {
diff --git a/lib/private/Files/ObjectStore/Mapper.php b/lib/private/Files/ObjectStore/Mapper.php
index bfb4e998150..81f8a9e3fa5 100644
--- a/lib/private/Files/ObjectStore/Mapper.php
+++ b/lib/private/Files/ObjectStore/Mapper.php
@@ -44,10 +44,12 @@ class Mapper {
}
/**
+ * @param int $numBuckets
* @return string
*/
- public function getBucket() {
+ public function getBucket($numBuckets = 64) {
$hash = md5($this->user->getUID());
- return substr($hash, 0, 3);
+ $num = hexdec(substr($hash, 0, 4));
+ return (string)($num % $numBuckets);
}
-} \ No newline at end of file
+}