2
0
mirror of https://github.com/moebooru/moebooru synced 2025-08-23 18:37:09 +00:00
moebooru/lib/tasks/check_missing.rake

13 lines
440 B
Ruby
Raw Permalink Normal View History

desc "find if there's any posts missing on file system"
task :find_posts => :environment do
2014-08-23 20:22:31 +09:00
images_path = "#{Rails.root}/public/data/image/"
2014-08-23 20:22:31 +09:00
Post.find(:all, :conditions => ["status != 'deleted'"], :order => "id DESC").each do |post|
md5 = post.md5
ext = post.file_ext
path = "#{images_path}/#{md5[0..1]}/#{md5[2..3]}"
file_name = "#{path}/#{md5}.#{ext}"
puts "#{md5}.#{ext}" unless File.exist?(file_name)
end
end