From f560a9999a6234eccd25c7a6cc48c42b0e5b6234 Mon Sep 17 00:00:00 2001 From: zmagod Date: Fri, 13 Jan 2017 14:14:41 +0100 Subject: [PATCH 1/2] adds rake task for repocess file thumbnails [fixes SCI-831] --- lib/tasks/paperclip.rake | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/tasks/paperclip.rake b/lib/tasks/paperclip.rake index 53d6af864..1792c138d 100644 --- a/lib/tasks/paperclip.rake +++ b/lib/tasks/paperclip.rake @@ -22,10 +22,26 @@ namespace :paperclip do end end - desc "List all paperclip files" + desc 'List all paperclip files' task files: :environment do print_model_files Asset, :file print_model_files User, :avatar end + desc 'Reprocess the Assets attachents styles' + task reprocess: :environment do + error = false + Asset.find_each(batch_size: 100) do |asset| + next unless asset.is_image? + begin + asset.file.reprocess! :medium, :large + rescue + error = true + $stderr.puts "exception while processing #{asset.file_file_name} " \ + "ID: #{asset.id}:" + end + end + $stderr.puts 'All gone well! ' \ + 'You can grab a beer now and enjoy the evening.' unless error + end end From e1ed1b74f8984ab9c2d378a35a5bdf3127edf6de Mon Sep 17 00:00:00 2001 From: zmagod Date: Wed, 18 Jan 2017 08:02:11 +0100 Subject: [PATCH 2/2] fixes hound --- lib/tasks/paperclip.rake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tasks/paperclip.rake b/lib/tasks/paperclip.rake index 1792c138d..7d2df8af5 100644 --- a/lib/tasks/paperclip.rake +++ b/lib/tasks/paperclip.rake @@ -41,7 +41,9 @@ namespace :paperclip do "ID: #{asset.id}:" end end - $stderr.puts 'All gone well! ' \ - 'You can grab a beer now and enjoy the evening.' unless error + unless error + $stderr.puts 'All gone well! ' \ + 'You can grab a beer now and enjoy the evening.' + end end end