Merge pull request #11018 from colinux/ignore-invalid-images
ETQ tech, réduit l'impact d'images invalides sur sentry
This commit is contained in:
commit
1d2c8e15b2
2 changed files with 6 additions and 5 deletions
|
@ -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
|
||||||
|
|
|
@ -21,6 +21,7 @@ module AttachmentImageProcessorConcern
|
||||||
return if blob.attachments.size != 1
|
return if blob.attachments.size != 1
|
||||||
return if blob.attachments.last.record_type == "Export"
|
return if blob.attachments.last.record_type == "Export"
|
||||||
return if !blob.content_type.in?(PROCESSABLE_TYPES)
|
return if !blob.content_type.in?(PROCESSABLE_TYPES)
|
||||||
|
return if blob.byte_size.zero? # some empty files may be considered as image depending on filename
|
||||||
|
|
||||||
ImageProcessorJob.perform_later(blob)
|
ImageProcessorJob.perform_later(blob)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue