mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
Merge 7848dfb294 into d09b8c99de
This commit is contained in:
commit
1c82bf5599
2 changed files with 6 additions and 2 deletions
|
|
@ -30,6 +30,10 @@ class Mapper {
|
|||
? (int)$this->config['arguments']['min_bucket']
|
||||
: 0;
|
||||
|
||||
if ($minBucket === $numBuckets) {
|
||||
return (string)$minBucket;
|
||||
}
|
||||
|
||||
$hash = md5($this->user->getUID());
|
||||
$num = hexdec(substr($hash, 0, 4));
|
||||
return (string)(($num % ($numBuckets - $minBucket)) + $minBucket);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class MapperTest extends \Test\TestCase {
|
|||
public static function dataGetBucket(): array {
|
||||
return [
|
||||
['user', 64, 0, '17'],
|
||||
['user', 64, 64, '64'],
|
||||
['USER', 64, 0, '0'],
|
||||
['bc0e8b52-a66c-1035-90c6-d9663bda9e3f', 64, 0, '56'],
|
||||
['user', 8, 0, '1'],
|
||||
|
|
@ -41,8 +42,7 @@ class MapperTest extends \Test\TestCase {
|
|||
#[\PHPUnit\Framework\Attributes\DataProvider('dataGetBucket')]
|
||||
public function testGetBucket($username, $numBuckets, $bucketShift, $expectedBucket): void {
|
||||
$mapper = new Mapper($this->user, ['arguments' => ['min_bucket' => $bucketShift]]);
|
||||
$this->user->expects($this->once())
|
||||
->method('getUID')
|
||||
$this->user->method('getUID')
|
||||
->willReturn($username);
|
||||
|
||||
$result = $mapper->getBucket($numBuckets);
|
||||
|
|
|
|||
Loading…
Reference in a new issue