mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-16 10:06:57 +08:00
adds rake task for repocess file thumbnails [fixes SCI-831]
This commit is contained in:
parent
f3b462bccb
commit
f560a9999a
1 changed files with 17 additions and 1 deletions
|
@ -22,10 +22,26 @@ 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
|
||||||
|
$stderr.puts 'All gone well! ' \
|
||||||
|
'You can grab a beer now and enjoy the evening.' unless error
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue