retry 5 times on integrity error and then block processing
This commit is contained in:
parent
8549d73a20
commit
d552e364fc
3 changed files with 29 additions and 1 deletions
|
@ -11,7 +11,16 @@ class VirusScannerJob < ApplicationJob
|
|||
# If the file is not analyzed yet, retry later (to avoid clobbering metadata)
|
||||
retry_on FileNotAnalyzedYetError, wait: :exponentially_longer, attempts: 10
|
||||
# If for some reason the file appears invalid, retry for a while
|
||||
retry_on ActiveStorage::IntegrityError, attempts: 10, wait: 5.seconds
|
||||
retry_on(ActiveStorage::IntegrityError, attempts: 5, wait: 5.seconds) do |job, _error|
|
||||
blob = job.arguments.first
|
||||
|
||||
metadata = {
|
||||
virus_scan_result: ActiveStorage::VirusScanner::INTEGRITY_ERROR,
|
||||
scanned_at: Time.zone.now
|
||||
}
|
||||
|
||||
blob.update!(metadata: blob.metadata.merge(metadata))
|
||||
end
|
||||
|
||||
def perform(blob)
|
||||
if !blob.analyzed? then raise FileNotAnalyzedYetError end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue