bug fixes for iqdb

This commit is contained in:
r888888888
2014-03-26 17:20:34 -07:00
parent 594b09b8c9
commit c41d2a733b
3 changed files with 9 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ module Iqdb
end
def process(&block)
IO.popen("iqdb #{database}", "w", &block)
IO.popen("iqdb command #{database}", "w", &block)
end
def add(post)

View File

@@ -13,7 +13,7 @@ module Iqdb
end
def open
@socket = TCPSocket.new(hostname, port)
@socket = TCPSocket.open(hostname, port)
end
def close
@@ -31,13 +31,17 @@ module Iqdb
request do
hex = post.id.to_s(16)
socket.puts "add 0 #{hex}:#{post.preview_file_path}"
socket.puts "done"
socket.read
end
end
def remove(post_id)
request do
hext = post_id.to_s(16)
hex = post_id.to_s(16)
socket.puts "remove 0 #{hex}"
socket.puts "done"
socket.read
end
end

View File

@@ -1282,7 +1282,7 @@ class Post < ActiveRecord::Base
end
def update_iqdb_async
if Danbooru.config.iqdb_hostname_and_port
if Danbooru.config.iqdb_hostname_and_port && File.exists?(preview_file_path)
Danbooru.config.all_server_hosts.each do |host|
delay(:queue => host).update_iqdb
end
@@ -1290,7 +1290,7 @@ class Post < ActiveRecord::Base
end
def remove_iqdb_async
if Danbooru.config.iqdb_hostname_and_port
if Danbooru.config.iqdb_hostname_and_port && File.exists?(preview_file_path)
Danbooru.config.all_server_hosts.each do |host|
Post.delay(:queue => host).remove_iqdb(id)
end