Merge pull request #407 from ZmagoD/zd_SCI_831

adds rake task for repocess file thumbnails [fixes SCI-831]
This commit is contained in:
Zmago Devetak 2017-01-18 11:09:03 +01:00 committed by GitHub
commit 0520690e8d

View file

@ -22,10 +22,28 @@ namespace :paperclip do
end end
end end
desc "List all paperclip files" desc 'List all paperclip files'
task files: :environment do task files: :environment do
print_model_files Asset, :file print_model_files Asset, :file
print_model_files User, :avatar print_model_files User, :avatar
end 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
unless error
$stderr.puts 'All gone well! ' \
'You can grab a beer now and enjoy the evening.'
end
end
end end