Skip to content

Commit

Permalink
fix(s3): Add config option to disable multipart copy for certain s3 p…
Browse files Browse the repository at this point in the history
…roviders

Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr authored and backportbot-nextcloud[bot] committed Dec 29, 2023
1 parent ad5be4f commit f5fe531
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/private/Files/ObjectStore/S3ConnectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ trait S3ConnectionTrait {
/** @var int */
private $copySizeLimit;

private bool $useMultipartCopy = true;

protected $test;

protected function parseParams($params) {
Expand All @@ -91,6 +93,7 @@ protected function parseParams($params) {
$this->uploadPartSize = $params['uploadPartSize'] ?? 524288000;
$this->putSizeLimit = $params['putSizeLimit'] ?? 104857600;
$this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000;
$this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true);
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
if (!isset($params['port']) || $params['port'] === '') {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/ObjectStore/S3ObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function copyObject($from, $to, array $options = []) {

$size = (int)($sourceMetadata->get('Size') ?? $sourceMetadata->get('ContentLength'));

if ($size > $this->copySizeLimit) {
if ($this->useMultipartCopy && $size > $this->copySizeLimit) {
$copy = new MultipartCopy($this->getConnection(), [
"source_bucket" => $this->getBucket(),
"source_key" => $from
Expand Down

0 comments on commit f5fe531

Please sign in to comment.