Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 22:34:23 +0300
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 22:34:23 +0300
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /config/initializers/carrierwave_patch.rb
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'config/initializers/carrierwave_patch.rb')
-rw-r--r--config/initializers/carrierwave_patch.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/config/initializers/carrierwave_patch.rb b/config/initializers/carrierwave_patch.rb
index ad3ff36138f..c8c6f75949c 100644
--- a/config/initializers/carrierwave_patch.rb
+++ b/config/initializers/carrierwave_patch.rb
@@ -17,7 +17,24 @@ module CarrierWave
class Fog < Abstract
class File
def copy_to(new_path)
- connection.copy_object(@uploader.fog_directory, file.key, @uploader.fog_directory, new_path, copy_to_options)
+ # fog-aws needs multipart uploads to copy files above 5 GB,
+ # and it is currently the only Fog provider that supports
+ # multithreaded uploads (https://github.com/fog/fog-aws/pull/579).
+ # Multithreaded uploads are essential for copying large amounts of data
+ # within the request timeout.
+ if ::Feature.enabled?(:s3_multithreaded_uploads, default_enabled: true) && fog_provider == 'AWS'
+ # AWS SDK uses 10 threads by default and a multipart chunk size of 10 MB
+ file.concurrency = 10
+ file.multipart_chunk_size = 10485760
+ file.copy(@uploader.fog_directory, new_path, copy_to_options)
+ else
+ # Some Fog providers may issue a GET request (https://github.com/fog/fog-google/issues/512)
+ # instead of a HEAD request after the transfer completes,
+ # which might cause the file to be downloaded locally.
+ # We fallback to the original copy_object for non-AWS providers.
+ connection.copy_object(@uploader.fog_directory, file.key, @uploader.fog_directory, new_path, copy_to_options)
+ end
+
CarrierWave::Storage::Fog::File.new(@uploader, @base, new_path)
end