0.9.3.5: only generate thumbnails on known extensions, remove trailing '/' from config.files and config.thumbnails
All checks were successful
File-uploader-crystal CI / build (push) Successful in 2m20s

This commit is contained in:
Fijxu 2024-11-26 20:56:58 -03:00
parent bb9ecee67b
commit c554b772c8
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
2 changed files with 13 additions and 0 deletions

View file

@ -85,5 +85,12 @@ class Config
puts "Config: fileameLength cannot be #{config.fileameLength}" puts "Config: fileameLength cannot be #{config.fileameLength}"
exit(1) exit(1)
end end
if config.files.ends_with?('/')
config.files = config.files.chomp('/')
end
if config.thumbnails.ends_with?('/')
config.thumbnails = config.thumbnails.chomp('/')
end
end end
end end

View file

@ -115,6 +115,12 @@ module Utils
end end
def generate_thumbnail(filename, extension) def generate_thumbnail(filename, extension)
exts = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".webp", ".heic", ".jxl", ".avif", ".crw", ".dng",
".mp4", ".mkv", ".webm", ".avi", ".wmv", ".flv", "m4v", ".mov", ".amv", ".3gp", ".mpg", ".mpeg", ".yuv"]
# To prevent thumbnail generation on non image extensions
return if exts.none? do |ext|
extension.downcase.includes?(ext)
end
# Disable generation if false # Disable generation if false
return if !CONFIG.generateThumbnails || !CONFIG.thumbnails return if !CONFIG.generateThumbnails || !CONFIG.thumbnails
LOGGER.debug "Generating thumbnail for #{filename + extension} in background" LOGGER.debug "Generating thumbnail for #{filename + extension} in background"