Project

General

Profile

Feature #32898 » pdf-thumbnail-win.patch

Go MAEDA, 2021-03-31 15:40

View differences:

lib/redmine/platform.rb
20 20
module Redmine
21 21
  module Platform
22 22
    class << self
23
      def mswin64?
24
        mswin? && RUBY_PLATFORM.include?('x86_64')
25
      end
26

  
23 27
      def mswin?
24 28
        (/(:?mswin|mingw)/.match?(RUBY_PLATFORM)) ||
25 29
           (RUBY_PLATFORM == 'java' && /windows/i.match?(ENV['OS'] || ENV['os']))
lib/redmine/thumbnail.rb
24 24
    extend Redmine::Utils::Shell
25 25

  
26 26
    CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze
27
    GS_BIN = (Redmine::Configuration['gs_command'] || 'gs').freeze
27
    DEFAULT_GS_COMMAND =
28
      if Redmine::Platform.mswin?
29
        Redmine::Platform.mswin64? ? 'gswin64c' : 'gswin32c'
30
      else
31
        'gs'
32
      end
33
    GS_BIN = (Redmine::Configuration['gs_command'] || DEFAULT_GS_COMMAND).freeze
28 34
    ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png application/pdf)
29 35

  
30 36
    # Generates a thumbnail for the source image to target
......
73 79
    def self.gs_available?
74 80
      return @gs_available if defined?(@gs_available)
75 81

  
76
      if Redmine::Platform.mswin?
82
      begin
83
        `#{shell_quote GS_BIN} -version`
84
        @gs_available = $?.success?
85
      rescue
77 86
        @gs_available = false
78
      else
79
        begin
80
          `#{shell_quote GS_BIN} -version`
81
          @gs_available = $?.success?
82
        rescue
83
          @gs_available = false
84
        end
85 87
      end
86 88
      logger.warn("gs binary (#{GS_BIN}) not available") unless @gs_available
87 89
      @gs_available
(1-1/3)