7a67f1a802
We currently have many failed VirusScannerJob enqueued, because the
underlying blob is missing.
This PR fixes the issue by discarding the job in those cases (because if
the blob is gone, the job is never going to succeed).
The implementation is based on a similar issue encoutered by the
ActiveStorage::AnalyzeJob. See 06f8baf73c
12 lines
331 B
Ruby
12 lines
331 B
Ruby
class VirusScannerJob < ApplicationJob
|
|
discard_on ActiveRecord::RecordNotFound
|
|
|
|
def perform(blob)
|
|
metadata = extract_metadata_via_virus_scanner(blob)
|
|
blob.update!(metadata: blob.metadata.merge(metadata))
|
|
end
|
|
|
|
def extract_metadata_via_virus_scanner(blob)
|
|
ActiveStorage::VirusScanner.new(blob).metadata
|
|
end
|
|
end
|