From 981fd2091576f9bcb72f7c670afa8e979bc6be90 Mon Sep 17 00:00:00 2001 From: Vladislav-S Date: Fri, 26 May 2023 11:18:54 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BA=D0=B8=D1=80=D0=B8?= =?UTF-8?q?=D0=BB=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/paperclip.rb | 2 +- lib/paperclip/storage/no_cache_s3.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/paperclip.rb b/lib/paperclip.rb index e61d7c3..39ba262 100644 --- a/lib/paperclip.rb +++ b/lib/paperclip.rb @@ -220,7 +220,7 @@ module Paperclip attachment_definitions[name] = Attachment.build_class(name, options) const_set("#{name}_attachment".camelize, attachment_definitions[name]) - after_commit :save_attached_files + after_commit :save_attached_files, if: :persisted? after_commit :destroy_attached_files, on: :destroy after_commit :flush_attachment_jobs diff --git a/lib/paperclip/storage/no_cache_s3.rb b/lib/paperclip/storage/no_cache_s3.rb index e8d8653..e3e503e 100644 --- a/lib/paperclip/storage/no_cache_s3.rb +++ b/lib/paperclip/storage/no_cache_s3.rb @@ -134,7 +134,7 @@ module Paperclip def flush_writes # :nodoc: return if queued_for_write.empty? - + return if instance.destroyed? # если есть, что записывать (queued_for_write), значит, данные устарели instance[self.class.synced_field_name(self.class.main_store_id)] = false sync_to(self.class.main_store_id, queued_for_write) @@ -232,6 +232,7 @@ module Paperclip cache_control: "max-age=#{10.years.to_i}", acl: 'public-read' }.merge(self.class.upload_options) + files.each do |style, file| path = key(style) file.rewind