jobs: retry on ActiveStorage::IntegrityError during virus scan

This is the same setting than what ActiveStorage::AnalyzeJob uses.
This commit is contained in:
Pierre de La Morinerie 2021-03-11 18:36:25 +01:00
parent 3d76319424
commit 08094e5384

View file

@ -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))