Merge pull request #5982 from betagouv/ignore-integrity-errors

Jobs : lorsqu'une erreur ActiveStorage::IntegrityError se produit pendant le scan des virus, le job est maintenant automatiquement retenté plus tard.
This commit is contained in:
Pierre de La Morinerie 2021-03-16 10:58:53 +01:00 committed by GitHub
commit c14720d915
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,9 @@ class VirusScannerJob < ApplicationJob
# If the file is deleted during the scan, ignore the error # If the file is deleted during the scan, ignore the error
discard_on ActiveStorage::FileNotFoundError 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) def perform(blob)
metadata = extract_metadata_via_virus_scanner(blob) metadata = extract_metadata_via_virus_scanner(blob)
blob.update!(metadata: blob.metadata.merge(metadata)) blob.update!(metadata: blob.metadata.merge(metadata))