FIX: ignore SVGs when regenerating missing optimized images.

When running `rake uploads:regenerate_missing_optimized`,
a `Discourse::InvalidAccess` will be raised if an SVG
file is being processed as `OptimizedImage.prepend_decoder!`
doesn't support the svg extension. This commit simply copies
the original SVG file as the thumbnail, just like currently
`OptimizedImage.create_for` does.
This commit is contained in:
misaka4e21 2024-04-21 05:26:26 +08:00 committed by Régis Hanol
parent 6b36b31ee0
commit ba357dd6cc

View File

@ -353,7 +353,16 @@ def regenerate_missing_optimized
if File.exist?(original) && File.size(original) > 0
FileUtils.mkdir_p(File.dirname(thumbnail))
OptimizedImage.resize(original, thumbnail, optimized_image.width, optimized_image.height)
if upload.extension == "svg"
FileUtils.cp(original, thumbnail)
else
OptimizedImage.resize(
original,
thumbnail,
optimized_image.width,
optimized_image.height,
)
end
putc "#"
else
missing_uploads << original