Не перегружаем все стили в S3, если это SVG

This commit is contained in:
Nastia Gorokhova-Alekseeva
2022-09-01 15:09:57 +03:00
parent 4a5764c347
commit aae9732eb4
2 changed files with 6 additions and 2 deletions

View File

@@ -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

View File

@@ -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