diff --git a/app/logical/iqdb/importer.rb b/app/logical/iqdb/importer.rb index 69af8df9f..c12690b82 100644 --- a/app/logical/iqdb/importer.rb +++ b/app/logical/iqdb/importer.rb @@ -1,15 +1,15 @@ module Iqdb class Importer def import! - IO.popen("iqdb command #{Danbooru.config.iqdb_file}", "w") do |io| - Post.find_each do |post| + Post.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" end - io.puts "quit" end end end diff --git a/app/logical/iqdb/responses/collection.rb b/app/logical/iqdb/responses/collection.rb index 3832ffe33..862618bed 100644 --- a/app/logical/iqdb/responses/collection.rb +++ b/app/logical/iqdb/responses/collection.rb @@ -1,6 +1,8 @@ module Iqdb module Responses class Collection + attr_reader :responses + def initialize(response_string) @responses = response_string.split(/\n/).map do |string| ::Iqdb::Responses.const_get("Response_#{string[0..2]}").new(string[4..-1]) diff --git a/app/logical/iqdb/server.rb b/app/logical/iqdb/server.rb index d4f9175c1..efc2983e0 100644 --- a/app/logical/iqdb/server.rb +++ b/app/logical/iqdb/server.rb @@ -3,7 +3,7 @@ module Iqdb FLAG_SKETCH = 0x01 FLAG_GRAYSCALE = 0x02 FLAG_WIDTH_AS_SET = 0x08 - FLAG_DISCARD_COMMON_COEFFS = 0x16 + FLAG_DISCARD_COMMON_COEFFS = 0x10 attr_reader :hostname, :port, :socket @@ -48,6 +48,7 @@ module Iqdb def query(results, filename, flags = FLAG_DISCARD_COMMON_COEFFS) request do socket.puts "query 0 #{flags} #{results} #{filename}" + socket.puts "done" responses = Responses::Collection.new(@socket.read) end end