diff options
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 +} |