aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-11-29 17:31:34 +0100
committerJulius Härtl <jus@bitgrid.net>2023-12-28 15:31:37 +0100
commit1043c21b35f256619e4970a6fd0746b0dc2c9d3f (patch)
tree64baba6c14956561b591f2d0f9905f0f30f0e33b /lib
parent7812a02998fb9519071ac917ebf092901fdc0b82 (diff)
downloadnextcloud-server-1043c21b35f256619e4970a6fd0746b0dc2c9d3f.tar.gz
nextcloud-server-1043c21b35f256619e4970a6fd0746b0dc2c9d3f.zip
only do a multipart s3 copy when above the regular copy limit
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/ObjectStore/S3ConnectionTrait.php4
-rw-r--r--lib/private/Files/ObjectStore/S3ObjectTrait.php30
2 files changed, 23 insertions, 11 deletions
diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php
index 044c3cdc900..1a682567e0c 100644
--- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php
+++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php
@@ -71,6 +71,9 @@ trait S3ConnectionTrait {
/** @var int */
private $putSizeLimit;
+ /** @var int */
+ private $copySizeLimit;
+
protected $test;
protected function parseParams($params) {
@@ -87,6 +90,7 @@ trait S3ConnectionTrait {
$this->storageClass = !empty($params['storageClass']) ? $params['storageClass'] : 'STANDARD';
$this->uploadPartSize = $params['uploadPartSize'] ?? 524288000;
$this->putSizeLimit = $params['putSizeLimit'] ?? 104857600;
+ $this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000;
$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'] === '') {
diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php
index 217e1a1a2ff..65952a76a61 100644
--- a/lib/private/Files/ObjectStore/S3ObjectTrait.php
+++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php
@@ -196,16 +196,24 @@ trait S3ObjectTrait {
'Key' => $from,
] + $this->getSSECParameters());
- $copy = new MultipartCopy($this->getConnection(), [
- "source_bucket" => $this->getBucket(),
- "source_key" => $from
- ], array_merge([
- "bucket" => $this->getBucket(),
- "key" => $to,
- "acl" => "private",
- "params" => $this->getSSECParameters() + $this->getSSECParameters(true),
- "source_metadata" => $sourceMetadata
- ], $options));
- $copy->copy();
+ $size = (int)($sourceMetadata->get('Size') ?? $sourceMetadata->get('ContentLength'));
+
+ if ($size > $this->copySizeLimit) {
+ $copy = new MultipartCopy($this->getConnection(), [
+ "source_bucket" => $this->getBucket(),
+ "source_key" => $from
+ ], array_merge([
+ "bucket" => $this->getBucket(),
+ "key" => $to,
+ "acl" => "private",
+ "params" => $this->getSSECParameters() + $this->getSSECParameters(true),
+ "source_metadata" => $sourceMetadata
+ ], $options));
+ $copy->copy();
+ } else {
+ $this->getConnection()->copy($this->getBucket(), $from, $this->getBucket(), $to, 'private', array_merge([
+ 'params' => $this->getSSECParameters() + $this->getSSECParameters(true)
+ ], $options));
+ }
}
}