diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-11-02 22:05:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-02 22:05:57 +0100 |
commit | c1feae1684934bb52b1edaa67d33d01b377b875a (patch) | |
tree | 1a278d6b1f0a0204d6ac1b4cd17034c4bbb6d8d6 /lib | |
parent | b4cf559707b48bca6d52194dec87d84a5597c317 (diff) | |
parent | 049bcae29ebf6106b33dd44f3be30e2a8486cd98 (diff) | |
download | nextcloud-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.php | 3 | ||||
-rw-r--r-- | lib/private/Files/ObjectStore/Mapper.php | 8 |
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 +} |