Skip to content

Commit

Permalink
attachment jobs: skip if not a valid attachment (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
PiTrem authored Jul 4, 2022
1 parent b8df27b commit 87cf147
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/jobs/transfer_file_from_tmp_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ def perform(attach_ary)
primary_store = Rails.configuration.storage.primary_store
begin
attach_ary.each do |attach_id|
attachment = Attachment.find(attach_id)
attachment = Attachment.find_by(id: attach_id)
next unless attachment

if attachment.storage == 'tmp'
attachment.update!(storage: primary_store)
end
Expand Down
4 changes: 3 additions & 1 deletion app/jobs/transfer_thumbnail_to_public_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ class TransferThumbnailToPublicJob < ApplicationJob
queue_as :transfer_thumbnail_to_public
def perform(attach_ary)
attach_ary.each do |attach_id|
a = Attachment.find(attach_id)
a = Attachment.find_by(id: attach_id)
next unless a

file_path = Rails.public_path.join('images', 'thumbnail', a.identifier)
File.write(file_path, a.read_thumbnail.force_encoding('UTF-8')) if a.read_thumbnail
end
Expand Down

0 comments on commit 87cf147

Please sign in to comment.