mirror of
https://github.com/moebooru/moebooru
synced 2025-08-22 09:57:31 +00:00
13 lines
433 B
Ruby
13 lines
433 B
Ruby
desc "find if there's any posts missing on file system"
|
|
task find_posts: :environment do
|
|
images_path = "#{Rails.root}/public/data/image/"
|
|
|
|
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
|