convert-timeout.patch

Go MAEDA, 2022-07-29 11:27

Download (1.33 KB)

View differences:

lib/redmine/thumbnail.rb
24 24
    extend Redmine::Utils::Shell
25 25

  
26 26
    CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze
27
    CONVERT_TIMEOUT = 10
27 28
    GS_BIN = (
28 29
      Redmine::Configuration['gs_command'] ||
29 30
      ('gswin64c' if Redmine::Platform.mswin?) ||
......
47 48
        size_option = "#{size}x#{size}>"
48 49

  
49 50
        if is_pdf
50
          cmd = "#{shell_quote CONVERT_BIN} #{shell_quote "#{source}[0]"} -thumbnail #{shell_quote size_option} #{shell_quote "png:#{target}"}"
51
          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}"}"
51 52
        else
52
          cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -auto-orient -thumbnail #{shell_quote size_option} #{shell_quote target}"
53
          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}"
53 54
        end
54 55
        unless system(cmd)
55 56
          logger.error("Creating thumbnail failed (#{$?}):\nCommand: #{cmd}")