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
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-08-03 00:55:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-08-03 00:55:37 +0300
commitb01dcc25b5a915e18ef16773048852bd1a4600c0 (patch)
tree63bf185562a740cccc72c69ce252a90ddee04700 /app
parent806bc80d8a8ca536ad4cd598eb6f47b2d396ee04 (diff)
Add latest changes from gitlab-org/gitlab@16-2-stable-ee
Diffstat (limited to 'app')
-rw-r--r--app/uploaders/object_storage.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/uploaders/object_storage.rb b/app/uploaders/object_storage.rb
index a8328304e73..2c7b50fc131 100644
--- a/app/uploaders/object_storage.rb
+++ b/app/uploaders/object_storage.rb
@@ -25,7 +25,29 @@ module ObjectStorage
end
class DirectUploadStorage < ::CarrierWave::Storage::Fog
+ extend ::Gitlab::Utils::Override
+
+ # This override only applies to object storage uploaders (e.g JobArtifactUploader).
+ # - The DirectUploadStorage is only used when object storage is enabled. See `#storage_for`
+ # - This method is called in two possible ways:
+ # - When a model (e.g. JobArtifact) is saved
+ # - When uploader.replace_file_without_saving! is called directly
+ # - For example, see `Gitlab::Geo::Replication::BlobDownloader#download_file`
+ # - We need this override to add the special behavior that bypasses
+ # CarrierWave's default storing mechanism, which copies a tempfile
+ # to its final location. In the case of files that are directly uploaded
+ # by Workhorse to the final location (determined by presence of `<mounted_as>_final_path`) in
+ # the object storage, the extra copy/delete step of CarrierWave
+ # is unnecessary.
+ # - We also need to ensure to only bypass the default store behavior if the file given
+ # is a `CarrierWave::Storage::Fog::File` (uploaded to object storage) and with `<mounted_as>_final_path`
+ # defined. For everything else, we want to still use the default CarrierWave storage behavior.
+ # - For example, during Geo replication of job artifacts, `replace_file_without_saving!` is
+ # called with a sanitized Tempfile. In this case, we want to use the default behavior of
+ # moving the tempfile to its final location and let CarrierWave upload the file to object storage.
+ override :store!
def store!(file)
+ return super unless file.is_a?(::CarrierWave::Storage::Fog::File)
return super unless @uploader.direct_upload_final_path.present?
# The direct_upload_final_path is defined which means