From 08094e538429b9f3aeb09b84bcc7b062652176fc Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 11 Mar 2021 18:36:25 +0100 Subject: [PATCH] jobs: retry on ActiveStorage::IntegrityError during virus scan This is the same setting than what ActiveStorage::AnalyzeJob uses. --- app/jobs/virus_scanner_job.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/jobs/virus_scanner_job.rb b/app/jobs/virus_scanner_job.rb index 29e6f1db6..3907ee4b6 100644 --- a/app/jobs/virus_scanner_job.rb +++ b/app/jobs/virus_scanner_job.rb @@ -6,6 +6,9 @@ class VirusScannerJob < ApplicationJob # If the file is deleted during the scan, ignore the error discard_on ActiveStorage::FileNotFoundError + # If for some reason the file appears invalid, retry for a while + retry_on ActiveStorage::IntegrityError, attempts: 10, wait: 5.seconds + def perform(blob) metadata = extract_metadata_via_virus_scanner(blob) blob.update!(metadata: blob.metadata.merge(metadata))