From aae9732eb42399d78266d39b98c560ae9ad1130f Mon Sep 17 00:00:00 2001 From: Nastia Gorokhova-Alekseeva Date: Thu, 1 Sep 2022 15:09:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B3?= =?UTF-8?q?=D1=80=D1=83=D0=B6=D0=B0=D0=B5=D0=BC=20=D0=B2=D1=81=D0=B5=20?= =?UTF-8?q?=D1=81=D1=82=D0=B8=D0=BB=D0=B8=20=D0=B2=20S3,=20=D0=B5=D1=81?= =?UTF-8?q?=D0=BB=D0=B8=20=D1=8D=D1=82=D0=BE=20SVG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/paperclip/attachment.rb | 6 +++++- lib/paperclip/storage/no_cache_s3.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/paperclip/attachment.rb b/lib/paperclip/attachment.rb index 4d06464..dc5a418 100644 --- a/lib/paperclip/attachment.rb +++ b/lib/paperclip/attachment.rb @@ -414,7 +414,7 @@ module Paperclip end def post_process #:nodoc: - return if !content_type.include?('image') || content_type.include?('svg') + return unless subject_to_post_process? return if queued_for_write[:original].nil? instance.run_paperclip_callbacks(:post_process) do @@ -473,5 +473,9 @@ module Paperclip file.write(body) file.tap(&:flush).tap(&:rewind) end + + def subject_to_post_process? + content_type.include?('image') && !content_type.include?('svg') + end end end diff --git a/lib/paperclip/storage/no_cache_s3.rb b/lib/paperclip/storage/no_cache_s3.rb index 5177002..6a73e0d 100644 --- a/lib/paperclip/storage/no_cache_s3.rb +++ b/lib/paperclip/storage/no_cache_s3.rb @@ -159,7 +159,7 @@ module Paperclip return unless instance.respond_to?(synced_field_name) return true if instance.public_send(synced_field_name) - styles_to_upload = content_type.include?('image') ? self.class.all_styles : [:original] + styles_to_upload = subject_to_post_process? ? self.class.all_styles : [:original] files ||= styles_to_upload.each_with_object({}) do |style, result| file = to_file(style, self.class.main_store_id) # For easier monitoring