diff --git a/apps/files/lib/Service/ChunkedUploadConfig.php b/apps/files/lib/Service/ChunkedUploadConfig.php index 29661750f8b07..0bf83b649c7f9 100644 --- a/apps/files/lib/Service/ChunkedUploadConfig.php +++ b/apps/files/lib/Service/ChunkedUploadConfig.php @@ -25,6 +25,6 @@ public static function setMaxChunkSize(int $maxChunkSize): void { } public static function getMaxParallelCount(): int { - return Server::get(IConfig::class)->getSystemValueInt(self::KEY_MAX_PARALLEL_COUNT, 5); + return max(1, Server::get(IConfig::class)->getSystemValueInt(self::KEY_MAX_PARALLEL_COUNT, 5)); } } diff --git a/apps/files/tests/Service/ChunkedUploadConfigTest.php b/apps/files/tests/Service/ChunkedUploadConfigTest.php new file mode 100644 index 0000000000000..9b0f51f2d26c0 --- /dev/null +++ b/apps/files/tests/Service/ChunkedUploadConfigTest.php @@ -0,0 +1,50 @@ +config = $this->createMock(IConfig::class); + $this->overwriteService(IConfig::class, $this->config); + } + + protected function tearDown(): void { + $this->restoreAllServices(); + parent::tearDown(); + } + + public static function dataGetMaxParallelCount(): array { + return [ + 'configured positive value' => [3, 3], + 'boundary minimum' => [1, 1], + 'zero becomes one' => [0, 1], + 'negative becomes one' => [-2, 1], + 'large value passes through' => [100, 100], + ]; + } + + #[DataProvider('dataGetMaxParallelCount')] + public function testGetMaxParallelCount(int $configuredValue, int $expectedValue): void { + $this->config->expects($this->once()) + ->method('getSystemValueInt') + ->with('files.chunked_upload.max_parallel_count', 5) + ->willReturn($configuredValue); + + $this->assertSame($expectedValue, ChunkedUploadConfig::getMaxParallelCount()); + } +} diff --git a/config/config.sample.php b/config/config.sample.php index 37383addea277..f4794aec4a890 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -2916,7 +2916,7 @@ /** * Maximum number of chunks uploaded in parallel during chunked uploads. Higher * counts increase throughput but consume more server resources, with diminishing - * returns. + * returns. Value must be a positive integer. * * Defaults to ``5`` */