Skip to content

Commit f64aa95

Browse files
committed
fix: Allow num_buckets to be equal as min_bucket
Signed-off-by: Kostiantyn Miakshyn <[email protected]>
1 parent bbca4fe commit f64aa95

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/private/Files/ObjectStore/Mapper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public function getBucket(int $numBuckets = 64): string {
3030
? (int)$this->config['arguments']['min_bucket']
3131
: 0;
3232

33+
if ($minBucket === $numBuckets) {
34+
return (string)$minBucket;
35+
}
36+
3337
$hash = md5($this->user->getUID());
3438
$num = hexdec(substr($hash, 0, 4));
3539
return (string)(($num % ($numBuckets - $minBucket)) + $minBucket);

tests/lib/Files/ObjectStore/MapperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ protected function setUp(): void {
2424
public static function dataGetBucket(): array {
2525
return [
2626
['user', 64, 0, '17'],
27+
['user', 64, 64, '64'],
2728
['USER', 64, 0, '0'],
2829
['bc0e8b52-a66c-1035-90c6-d9663bda9e3f', 64, 0, '56'],
2930
['user', 8, 0, '1'],

0 commit comments

Comments
 (0)