chore(gallery): add activestorage error catching in job
This commit is contained in:
parent
ffc0ddc446
commit
f6e54a540b
1 changed files with 14 additions and 0 deletions
|
@ -10,6 +10,10 @@ class ImageProcessorJob < ApplicationJob
|
||||||
# (to avoid modifying the file while it is being scanned).
|
# (to avoid modifying the file while it is being scanned).
|
||||||
retry_on FileNotScannedYetError, wait: :exponentially_longer, attempts: 10
|
retry_on FileNotScannedYetError, wait: :exponentially_longer, attempts: 10
|
||||||
|
|
||||||
|
rescue_from ActiveStorage::PreviewError do
|
||||||
|
retry_or_discard
|
||||||
|
end
|
||||||
|
|
||||||
def perform(blob)
|
def perform(blob)
|
||||||
return if blob.nil?
|
return if blob.nil?
|
||||||
raise FileNotScannedYetError if blob.virus_scanner.pending?
|
raise FileNotScannedYetError if blob.virus_scanner.pending?
|
||||||
|
@ -58,4 +62,14 @@ class ImageProcessorJob < ApplicationJob
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def retry_or_discard
|
||||||
|
if executions < max_attempts
|
||||||
|
retry_job wait: 5.minutes
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def max_attempts
|
||||||
|
3
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue