iqdb command fixes

This commit is contained in:
r888888888
2014-05-05 17:21:18 -07:00
committed by Toks
parent b18bb73f4b
commit 6c4cd42565
2 changed files with 6 additions and 3 deletions

View File

@@ -7,7 +7,7 @@ module Iqdb
end
def process(&block)
IO.popen("iqdb command #{database}", "w", &block)
IO.popen("iqdb command #{database}", "w+", &block)
end
def add(post)
@@ -15,6 +15,7 @@ module Iqdb
process do |io|
io.puts "add 0 #{hex}:#{post.preview_file_path}"
io.puts "quit"
io.read
end
end
@@ -23,6 +24,7 @@ module Iqdb
process do |io|
io.puts "remove 0 #{hex}"
io.puts "quit"
io.read
end
end
end

View File

@@ -1,14 +1,15 @@
module Iqdb
class Importer
def import!
Post.find_each do |post|
IO.popen("iqdb command #{Danbooru.config.iqdb_file}", "w") do |io|
Post.where("created_at >= ?", 3.months.ago).find_each do |post|
IO.popen("iqdb command #{Danbooru.config.iqdb_file}", "w+") do |io|
if File.exists?(post.preview_file_path)
puts post.id
hex = post.id.to_s(16)
io.puts "add 0 #{hex}:#{post.preview_file_path}"
end
io.puts "quit"
io.read
end
end
end