diff --git a/app/jobs/virus_scanner_job.rb b/app/jobs/virus_scanner_job.rb index f20d4bfc1..99b2175af 100644 --- a/app/jobs/virus_scanner_job.rb +++ b/app/jobs/virus_scanner_job.rb @@ -1,4 +1,6 @@ class VirusScannerJob < ApplicationJob + discard_on ActiveRecord::RecordNotFound + def perform(blob) metadata = extract_metadata_via_virus_scanner(blob) blob.update!(metadata: blob.metadata.merge(metadata)) diff --git a/spec/jobs/virus_scanner_job_spec.rb b/spec/jobs/virus_scanner_job_spec.rb index 237520b36..8b0885ad4 100644 --- a/spec/jobs/virus_scanner_job_spec.rb +++ b/spec/jobs/virus_scanner_job_spec.rb @@ -35,4 +35,14 @@ RSpec.describe VirusScannerJob, type: :job do it { expect(champ.reload.piece_justificative_file.virus_scanner.infected?).to be_truthy } end + + context "when the blob has been deleted" do + before do + Champ.find(champ.id).piece_justificative_file.purge + end + + it "ignores the error" do + expect { subject }.not_to raise_error + end + end end