Don't push to cache buster if attachment path is nil (#31414)

This commit is contained in:
Jeong Arm 2024-08-14 17:57:42 +09:00 committed by GitHub
parent 8d96907933
commit 95c11d365d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 3 deletions

View File

@ -422,7 +422,7 @@ class MediaAttachment < ApplicationRecord
attachment = public_send(attachment_name) attachment = public_send(attachment_name)
styles = DEFAULT_STYLES | attachment.styles.keys styles = DEFAULT_STYLES | attachment.styles.keys
styles.map { |style| attachment.path(style) } styles.map { |style| attachment.path(style) }
end end.compact
rescue => e rescue => e
# We really don't want any error here preventing media deletion # We really don't want any error here preventing media deletion
Rails.logger.warn "Error #{e.class} busting cache: #{e.message}" Rails.logger.warn "Error #{e.class} busting cache: #{e.message}"

View File

@ -302,12 +302,10 @@ RSpec.describe MediaAttachment, :attachment_processing do
it 'queues CacheBusterWorker jobs' do it 'queues CacheBusterWorker jobs' do
original_path = media.file.path(:original) original_path = media.file.path(:original)
small_path = media.file.path(:small) small_path = media.file.path(:small)
thumbnail_path = media.thumbnail.path(:original)
expect { media.destroy } expect { media.destroy }
.to enqueue_sidekiq_job(CacheBusterWorker).with(original_path) .to enqueue_sidekiq_job(CacheBusterWorker).with(original_path)
.and enqueue_sidekiq_job(CacheBusterWorker).with(small_path) .and enqueue_sidekiq_job(CacheBusterWorker).with(small_path)
.and enqueue_sidekiq_job(CacheBusterWorker).with(thumbnail_path)
end end
end end