mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #4824 from tgxworld/fix_optimize_image_timeout
Fix optimize image timeout
This commit is contained in:
commit
94c7be3ca6
@ -9,3 +9,4 @@ pngout: false
|
|||||||
pngquant: false
|
pngquant: false
|
||||||
# JPG
|
# JPG
|
||||||
jpegrecompress: false
|
jpegrecompress: false
|
||||||
|
timeout: 15
|
||||||
|
4
Gemfile
4
Gemfile
@ -66,7 +66,9 @@ gem 'unf', require: false
|
|||||||
|
|
||||||
gem 'email_reply_trimmer', '0.1.6'
|
gem 'email_reply_trimmer', '0.1.6'
|
||||||
|
|
||||||
gem 'image_optim'
|
# TODO Use official image_optim gem once https://github.com/toy/image_optim/pull/149
|
||||||
|
# is merged.
|
||||||
|
gem 'discourse_image_optim', require: 'image_optim'
|
||||||
gem 'multi_json'
|
gem 'multi_json'
|
||||||
gem 'mustache'
|
gem 'mustache'
|
||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
|
14
Gemfile.lock
14
Gemfile.lock
@ -79,6 +79,12 @@ GEM
|
|||||||
discourse-qunit-rails (0.0.9)
|
discourse-qunit-rails (0.0.9)
|
||||||
railties
|
railties
|
||||||
discourse_fastimage (2.0.3)
|
discourse_fastimage (2.0.3)
|
||||||
|
discourse_image_optim (0.24.4)
|
||||||
|
exifr (~> 1.2, >= 1.2.2)
|
||||||
|
fspath (~> 3.0)
|
||||||
|
image_size (~> 1.5)
|
||||||
|
in_threads (~> 1.3)
|
||||||
|
progress (~> 3.0, >= 3.0.1)
|
||||||
domain_name (0.5.25)
|
domain_name (0.5.25)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
email_reply_trimmer (0.1.6)
|
email_reply_trimmer (0.1.6)
|
||||||
@ -126,12 +132,6 @@ GEM
|
|||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
http_accept_language (2.0.5)
|
http_accept_language (2.0.5)
|
||||||
i18n (0.8.1)
|
i18n (0.8.1)
|
||||||
image_optim (0.24.2)
|
|
||||||
exifr (~> 1.2, >= 1.2.2)
|
|
||||||
fspath (~> 3.0)
|
|
||||||
image_size (~> 1.5)
|
|
||||||
in_threads (~> 1.3)
|
|
||||||
progress (~> 3.0, >= 3.0.1)
|
|
||||||
image_size (1.5.0)
|
image_size (1.5.0)
|
||||||
in_threads (1.4.0)
|
in_threads (1.4.0)
|
||||||
jmespath (1.3.1)
|
jmespath (1.3.1)
|
||||||
@ -405,6 +405,7 @@ DEPENDENCIES
|
|||||||
certified
|
certified
|
||||||
discourse-qunit-rails
|
discourse-qunit-rails
|
||||||
discourse_fastimage (= 2.0.3)
|
discourse_fastimage (= 2.0.3)
|
||||||
|
discourse_image_optim
|
||||||
email_reply_trimmer (= 0.1.6)
|
email_reply_trimmer (= 0.1.6)
|
||||||
ember-handlebars-template (= 0.7.5)
|
ember-handlebars-template (= 0.7.5)
|
||||||
ember-rails (= 0.18.5)
|
ember-rails (= 0.18.5)
|
||||||
@ -423,7 +424,6 @@ DEPENDENCIES
|
|||||||
hiredis
|
hiredis
|
||||||
htmlentities
|
htmlentities
|
||||||
http_accept_language (~> 2.0.5)
|
http_accept_language (~> 2.0.5)
|
||||||
image_optim
|
|
||||||
listen
|
listen
|
||||||
logster
|
logster
|
||||||
lru_redux
|
lru_redux
|
||||||
|
@ -155,7 +155,12 @@ class Upload < ActiveRecord::Base
|
|||||||
|
|
||||||
# optimize image (except GIFs, SVGs and large PNGs)
|
# optimize image (except GIFs, SVGs and large PNGs)
|
||||||
if should_optimize?(file.path, [w, h])
|
if should_optimize?(file.path, [w, h])
|
||||||
ImageOptim.new.optimize_image!(file.path) rescue nil
|
begin
|
||||||
|
ImageOptim.new.optimize_image!(file.path)
|
||||||
|
rescue ImageOptim::Worker::TimeoutExceeded
|
||||||
|
# Don't optimize if it takes too long
|
||||||
|
Rails.logger.warn("ImageOptim timed out while optimizing #{filename}")
|
||||||
|
end
|
||||||
# update the file size
|
# update the file size
|
||||||
filesize = File.size(file.path)
|
filesize = File.size(file.path)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user