chore(image): ignore invalid images files / formats

This commit is contained in:
Colin Darie 2024-11-05 16:57:16 +01:00
parent e95e86faae
commit 2656ec18af
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4

View file

@ -14,6 +14,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
# Usually invalid image or ImageMagick decoder blocked for this format
retry_on MiniMagick::Invalid, attempts: 3
retry_on MiniMagick::Error, attempts: 3
rescue_from ActiveStorage::PreviewError do rescue_from ActiveStorage::PreviewError do
retry_or_discard retry_or_discard
end end
@ -82,12 +86,8 @@ class ImageProcessorJob < ApplicationJob
end end
def retry_or_discard def retry_or_discard
if executions < max_attempts if executions < 3
retry_job wait: 5.minutes retry_job wait: 5.minutes
end end
end end
def max_attempts
3
end
end end