Project

General

Profile

Feature #37530 » convert-timeout.patch

Go MAEDA, 2022-07-29 11:27

View differences:

lib/redmine/thumbnail.rb
extend Redmine::Utils::Shell
CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze
CONVERT_TIMEOUT = 10
GS_BIN = (
Redmine::Configuration['gs_command'] ||
('gswin64c' if Redmine::Platform.mswin?) ||
......
size_option = "#{size}x#{size}>"
if is_pdf
cmd = "#{shell_quote CONVERT_BIN} #{shell_quote "#{source}[0]"} -thumbnail #{shell_quote size_option} #{shell_quote "png:#{target}"}"
cmd = "#{shell_quote CONVERT_BIN} -limit time #{shell_quote CONVERT_TIMEOUT.to_s} #{shell_quote "#{source}[0]"} -thumbnail #{shell_quote size_option} #{shell_quote "png:#{target}"}"
else
cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -auto-orient -thumbnail #{shell_quote size_option} #{shell_quote target}"
cmd = "#{shell_quote CONVERT_BIN} -limit time #{shell_quote CONVERT_TIMEOUT.to_s} #{shell_quote source} -auto-orient -thumbnail #{shell_quote size_option} #{shell_quote target}"
end
unless system(cmd)
logger.error("Creating thumbnail failed (#{$?}):\nCommand: #{cmd}")
(1-1/5)