2
0
mirror of https://github.com/moebooru/moebooru synced 2025-08-24 18:57:25 +00:00
moebooru/lib/tasks/check_missing.rake

13 lines
433 B
Ruby
Raw Normal View History

desc "find if there's any posts missing on file system"
2024-01-08 19:39:01 +09:00
task find_posts: :environment do
2014-08-23 20:22:31 +09:00
images_path = "#{Rails.root}/public/data/image/"
2024-01-08 19:39:01 +09:00
Post.find(:all, conditions: [ "status != 'deleted'" ], order: "id DESC").each do |post|
2014-08-23 20:22:31 +09:00
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