-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(files): Expose chunked upload config via capabilities
Signed-off-by: provokateurin <kate@provokateurin.de>
- Loading branch information
1 parent
4d8d11d
commit 51e971b
Showing
9 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
apps/files/lib/Migration/ChunkedUploadConfigRepairStep.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace OCA\Files\Migration; | ||
|
||
use OCA\Files\Service\ChunkedUploadConfig; | ||
use OCP\IConfig; | ||
use OCP\Migration\IOutput; | ||
use OCP\Migration\IRepairStep; | ||
use OCP\Server; | ||
|
||
class ChunkedUploadConfigRepairStep implements IRepairStep { | ||
public function getName() { | ||
return 'Migrate chunked upload config'; | ||
} | ||
|
||
public function run(IOutput $output) { | ||
$maxChunkSize = Server::get(IConfig::class)->getAppValue('files', 'max_chunk_size'); | ||
if ($maxChunkSize === '') { | ||
// Skip if no value was configured before | ||
return; | ||
} | ||
|
||
ChunkedUploadConfig::setMaxChunkSize((int)$maxChunkSize); | ||
Server::get(IConfig::class)->deleteAppValue('files', 'max_chunk_size'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Files\Service; | ||
|
||
use OCP\IConfig; | ||
use OCP\Server; | ||
|
||
class ChunkedUploadConfig { | ||
private const KEY_MAX_SIZE = 'files.chunked_upload.max_size'; | ||
private const KEY_MAX_PARALLEL_COUNT = 'files.chunked_upload.max_parallel_count'; | ||
|
||
public static function getMaxChunkSize(): int { | ||
return Server::get(IConfig::class)->getSystemValueInt(self::KEY_MAX_SIZE, 100 * 1024 * 1024); | ||
} | ||
|
||
public static function setMaxChunkSize(int $maxChunkSize): void { | ||
Server::get(IConfig::class)->setSystemValue(self::KEY_MAX_SIZE, $maxChunkSize); | ||
} | ||
|
||
public static function getMaxParallelCount(): int { | ||
return Server::get(IConfig::class)->getSystemValueInt(self::KEY_MAX_PARALLEL_COUNT, 5); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters