Merge pull request #5531 from betagouv/ignore-deleted-file-in-virus-scan

jobs: ignore deleted file in Virus Scan
This commit is contained in:
Paul Chavard 2020-09-03 13:10:42 +02:00 committed by GitHub
commit a51d6046dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,10 @@
class VirusScannerJob < ApplicationJob class VirusScannerJob < ApplicationJob
queue_as :active_storage_analysis queue_as :active_storage_analysis
# If by the time the job runs the blob has been deleted, ignore the error
discard_on ActiveRecord::RecordNotFound discard_on ActiveRecord::RecordNotFound
# If the file is deleted during the scan, ignore the error
discard_on ActiveStorage::FileNotFoundError
def perform(blob) def perform(blob)
metadata = extract_metadata_via_virus_scanner(blob) metadata = extract_metadata_via_virus_scanner(blob)