fix iqdb importer

This commit is contained in:
r888888888
2014-03-24 15:07:13 -07:00
parent a6aecfb60c
commit 91a0917477
2 changed files with 6 additions and 3 deletions

View File

@@ -1,12 +1,15 @@
module Iqdb
class Importer
def import!
IO.popen("iqdb add #{Rails.root}/danbooru.db", "w") do |io|
IO.popen("iqdb command #{Danbooru.config.iqdb_file}", "w") do |io|
Post.find_each do |post|
if File.exists?(post.preview_file_path)
io.puts "#{post.id.to_s(16)}:#{post.preview_file_path}"
puts post.id
hex = post.id.to_s(16)
io.puts "add 0 #{hex} :#{post.preview_file_path}"
end
end
io.puts "quit"
end
end
end

View File

@@ -2,4 +2,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
Iqdb::Server.import(Danbooru.config.iqdb_file)
Iqdb::Importer.import!