From cefdeddd2e24e53038aff68dddd932668a742da0 Mon Sep 17 00:00:00 2001 From: Godwin Date: Sun, 13 Jul 2014 17:36:05 -0600 Subject: [PATCH] Fix for regeneration task --- app/uploaders/cover_uploader.rb | 22 ++++++++++++++++++++++ app/uploaders/poster_uploader.rb | 6 +++++- lib/tasks/regenerate.rake | 3 --- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/uploaders/cover_uploader.rb b/app/uploaders/cover_uploader.rb index 1729166..c40dbcb 100644 --- a/app/uploaders/cover_uploader.rb +++ b/app/uploaders/cover_uploader.rb @@ -29,4 +29,26 @@ class CoverUploader < CarrierWave::Uploader::Base image['width'] > image['height'] end + def manipulate! + cache_stored_file! if !cached? + image = ::MiniMagick::Image.open(current_path) + + begin + image.format(@format.to_s.downcase) if @format + image = yield(image) + image.write(current_path) + begin + image.run_command("identify", current_path) + rescue + image.run_command("identify", '"' + current_path + '"') + end + ensure + image.destroy! + end + rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e + default = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :locale => :en) + message = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :default => default) + raise CarrierWave::ProcessingError, message + end + end diff --git a/app/uploaders/poster_uploader.rb b/app/uploaders/poster_uploader.rb index 1f33f94..a5922af 100644 --- a/app/uploaders/poster_uploader.rb +++ b/app/uploaders/poster_uploader.rb @@ -47,7 +47,11 @@ class PosterUploader < CarrierWave::Uploader::Base image.format(@format.to_s.downcase) if @format image = yield(image) image.write(current_path) - image.run_command("identify", Gem.win_platform? ? '"' + current_path + '"' : current_path) + begin + image.run_command("identify", current_path) + rescue + image.run_command("identify", '"' + current_path + '"') + end ensure image.destroy! end diff --git a/lib/tasks/regenerate.rake b/lib/tasks/regenerate.rake index cc99f7f..97836fb 100644 --- a/lib/tasks/regenerate.rake +++ b/lib/tasks/regenerate.rake @@ -3,11 +3,8 @@ namespace :regenerate do task conference_posters: :environment do Conference.all.each { |m| - #puts m.title - #puts m.poster m.poster.recreate_versions! } - #puts Conference.all.to_json.to_s end task organization_avatars: :environment do