aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Files/Mount/ObjectHomeMountProvider.php2
-rw-r--r--lib/private/Files/ObjectStore/Mapper.php17
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/private/Files/Mount/ObjectHomeMountProvider.php b/lib/private/Files/Mount/ObjectHomeMountProvider.php
index 441f7a2957e..972d3893e66 100644
--- a/lib/private/Files/Mount/ObjectHomeMountProvider.php
+++ b/lib/private/Files/Mount/ObjectHomeMountProvider.php
@@ -121,7 +121,7 @@ class ObjectHomeMountProvider implements IHomeMountProvider {
if (!isset($config['arguments']['bucket'])) {
$config['arguments']['bucket'] = '';
}
- $mapper = new \OC\Files\ObjectStore\Mapper($user);
+ $mapper = new \OC\Files\ObjectStore\Mapper($user, $this->config);
$numBuckets = isset($config['arguments']['num_buckets']) ? $config['arguments']['num_buckets'] : 64;
$config['arguments']['bucket'] .= $mapper->getBucket($numBuckets);
diff --git a/lib/private/Files/ObjectStore/Mapper.php b/lib/private/Files/ObjectStore/Mapper.php
index 74d65454b12..ef3c6878d81 100644
--- a/lib/private/Files/ObjectStore/Mapper.php
+++ b/lib/private/Files/ObjectStore/Mapper.php
@@ -22,6 +22,7 @@
*/
namespace OC\Files\ObjectStore;
+use OCP\IConfig;
use OCP\IUser;
/**
@@ -35,13 +36,18 @@ class Mapper {
/** @var IUser */
private $user;
+ /** @var IConfig */
+ private $config;
+
/**
* Mapper constructor.
*
* @param IUser $user
+ * @param IConfig $config
*/
- public function __construct(IUser $user) {
+ public function __construct(IUser $user, IConfig $config) {
$this->user = $user;
+ $this->config = $config;
}
/**
@@ -49,8 +55,15 @@ class Mapper {
* @return string
*/
public function getBucket($numBuckets = 64) {
+ // Get the bucket config and shift if provided.
+ // Allow us to prevent writing in old filled buckets
+ $config = $this->config->getSystemValue('objectstore_multibucket');
+ $minBucket = is_array($config) && isset($config['arguments']['min_bucket'])
+ ? (int)$config['arguments']['min_bucket']
+ : 0;
+
$hash = md5($this->user->getUID());
$num = hexdec(substr($hash, 0, 4));
- return (string)($num % $numBuckets);
+ return (string)(($num % ($numBuckets - $minBucket)) + $minBucket);
}
}