Files
danbooru/app/logical/iqdb/download.rb
Toks 99fb4e60ab Fix iqdb
file was getting deleted before it got used
2014-11-07 02:39:15 -05:00

23 lines
517 B
Ruby

module Iqdb
class Download
attr_reader :source, :download, :matches
def initialize(source)
@source = source
end
def download_and_find_similar
tempfile = Tempfile.new("iqdb-#{$PROCESS_ID}")
@download = Downloads::File.new(source, tempfile.path)
@download.download!
if Danbooru.config.iqdb_hostname_and_port
@matches = Iqdb::Server.default.query(3, @download.file_path).matches
end
ensure
tempfile.close
tempfile.unlink
end
end
end