From 6c4cd425652ef87cb0cbe9c94daf51e9c3c3ebf8 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Mon, 5 May 2014 17:21:18 -0700 Subject: [PATCH] iqdb command fixes --- app/logical/iqdb/command.rb | 4 +++- app/logical/iqdb/importer.rb | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/logical/iqdb/command.rb b/app/logical/iqdb/command.rb index 1b7d97644..4f19445c7 100644 --- a/app/logical/iqdb/command.rb +++ b/app/logical/iqdb/command.rb @@ -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 diff --git a/app/logical/iqdb/importer.rb b/app/logical/iqdb/importer.rb index c12690b82..efa359479 100644 --- a/app/logical/iqdb/importer.rb +++ b/app/logical/iqdb/importer.rb @@ -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