From 02a911be1a6de55be6e0c8803687f3c93fb8f391 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sat, 30 Jun 2018 22:29:48 +0900 Subject: [PATCH 1/3] Bump carrierwave gem version to 1.2.3 --- Gemfile.lock | 2 +- changelogs/unreleased/bump-carrierwave-to-1-2-3.yml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/bump-carrierwave-to-1-2-3.yml diff --git a/Gemfile.lock b/Gemfile.lock index 1cd336c95d0..9df44e0eda2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,7 +108,7 @@ GEM capybara-screenshot (1.0.14) capybara (>= 1.0, < 3) launchy - carrierwave (1.2.1) + carrierwave (1.2.3) activemodel (>= 4.0.0) activesupport (>= 4.0.0) mime-types (>= 1.16) diff --git a/changelogs/unreleased/bump-carrierwave-to-1-2-3.yml b/changelogs/unreleased/bump-carrierwave-to-1-2-3.yml new file mode 100644 index 00000000000..e5da64e0a10 --- /dev/null +++ b/changelogs/unreleased/bump-carrierwave-to-1-2-3.yml @@ -0,0 +1,5 @@ +--- +title: Bump carrierwave gem verion to 1.2.3 +merge_request: +author: +type: performance From 0766f870b7aca43cb40c171fd6d49ae2ee6879cb Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sat, 30 Jun 2018 22:31:45 +0900 Subject: [PATCH 2/3] Delete monkey patch --- .../initializers/carrierwave_monkey_patch.rb | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 config/initializers/carrierwave_monkey_patch.rb diff --git a/config/initializers/carrierwave_monkey_patch.rb b/config/initializers/carrierwave_monkey_patch.rb deleted file mode 100644 index 7543231cd4f..00000000000 --- a/config/initializers/carrierwave_monkey_patch.rb +++ /dev/null @@ -1,69 +0,0 @@ -# This fixes the problem https://gitlab.com/gitlab-org/gitlab-ce/issues/46182 that carrierwave eagerly loads upoloading files into memory -# There is an PR https://github.com/carrierwaveuploader/carrierwave/pull/2314 which has the identical change. -module CarrierWave - module Storage - class Fog < Abstract - class File - module MonkeyPatch - ## - # Read content of file from service - # - # === Returns - # - # [String] contents of file - def read - file_body = file.body - - return if file_body.nil? - return file_body unless file_body.is_a?(::File) - - # Fog::Storage::XXX::File#body could return the source file which was upoloaded to the remote server. - read_source_file(file_body) if ::File.exist?(file_body.path) - - # If the source file doesn't exist, the remote content is read - @file = nil # rubocop:disable Gitlab/ModuleWithInstanceVariables - file.body - end - - ## - # Write file to service - # - # === Returns - # - # [Boolean] true on success or raises error - def store(new_file) - if new_file.is_a?(self.class) # rubocop:disable Cop/LineBreakAroundConditionalBlock - new_file.copy_to(path) - else - fog_file = new_file.to_file - @content_type ||= new_file.content_type # rubocop:disable Gitlab/ModuleWithInstanceVariables - @file = directory.files.create({ # rubocop:disable Gitlab/ModuleWithInstanceVariables - :body => fog_file ? fog_file : new_file.read, # rubocop:disable Style/HashSyntax - :content_type => @content_type, # rubocop:disable Style/HashSyntax,Gitlab/ModuleWithInstanceVariables - :key => path, # rubocop:disable Style/HashSyntax - :public => @uploader.fog_public # rubocop:disable Style/HashSyntax,Gitlab/ModuleWithInstanceVariables - }.merge(@uploader.fog_attributes)) # rubocop:disable Gitlab/ModuleWithInstanceVariables - fog_file.close if fog_file && !fog_file.closed? - end - true - end - - private - - def read_source_file(file_body) - return unless ::File.exist?(file_body.path) - - begin - file_body = ::File.open(file_body.path) if file_body.closed? # Reopen if it's already closed - file_body.read - ensure - file_body.close - end - end - end - - prepend MonkeyPatch - end - end - end -end From 957167f3040ac3126ab22e3771b44738ac7601c5 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 4 Jul 2018 13:17:11 +0900 Subject: [PATCH 3/3] Add merge request number to changelog --- changelogs/unreleased/bump-carrierwave-to-1-2-3.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/unreleased/bump-carrierwave-to-1-2-3.yml b/changelogs/unreleased/bump-carrierwave-to-1-2-3.yml index e5da64e0a10..373ac48553e 100644 --- a/changelogs/unreleased/bump-carrierwave-to-1-2-3.yml +++ b/changelogs/unreleased/bump-carrierwave-to-1-2-3.yml @@ -1,5 +1,5 @@ --- title: Bump carrierwave gem verion to 1.2.3 -merge_request: +merge_request: 20287 author: type: performance