From c554b772c82fa3b897ed442b12dc71c75890c851 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Tue, 26 Nov 2024 20:56:58 -0300 Subject: [PATCH] 0.9.3.5: only generate thumbnails on known extensions, remove trailing '/' from config.files and config.thumbnails --- src/config.cr | 7 +++++++ src/utils.cr | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/config.cr b/src/config.cr index 606c120..77740f3 100644 --- a/src/config.cr +++ b/src/config.cr @@ -85,5 +85,12 @@ class Config puts "Config: fileameLength cannot be #{config.fileameLength}" exit(1) 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 diff --git a/src/utils.cr b/src/utils.cr index 499c651..083146e 100644 --- a/src/utils.cr +++ b/src/utils.cr @@ -115,6 +115,12 @@ module Utils end 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 return if !CONFIG.generateThumbnails || !CONFIG.thumbnails LOGGER.debug "Generating thumbnail for #{filename + extension} in background"