Fix iqdb
file was getting deleted before it got used
This commit is contained in:
@@ -19,8 +19,7 @@ class IqdbQueriesController < ApplicationController
|
|||||||
protected
|
protected
|
||||||
def create_by_url
|
def create_by_url
|
||||||
@download = Iqdb::Download.new(params[:url])
|
@download = Iqdb::Download.new(params[:url])
|
||||||
@download.download_from_source
|
@download.download_and_find_similar
|
||||||
@download.find_similar
|
|
||||||
@results = @download.matches
|
@results = @download.matches
|
||||||
render :layout => false, :action => "create_by_url"
|
render :layout => false, :action => "create_by_url"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,19 +6,17 @@ module Iqdb
|
|||||||
@source = source
|
@source = source
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_from_source
|
def download_and_find_similar
|
||||||
tempfile = Tempfile.new("iqdb-#{$PROCESS_ID}")
|
tempfile = Tempfile.new("iqdb-#{$PROCESS_ID}")
|
||||||
@download = Downloads::File.new(source, tempfile.path)
|
@download = Downloads::File.new(source, tempfile.path)
|
||||||
@download.download!
|
@download.download!
|
||||||
|
|
||||||
|
if Danbooru.config.iqdb_hostname_and_port
|
||||||
|
@matches = Iqdb::Server.default.query(3, @download.file_path).matches
|
||||||
|
end
|
||||||
ensure
|
ensure
|
||||||
tempfile.close
|
tempfile.close
|
||||||
tempfile.unlink
|
tempfile.unlink
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_similar
|
|
||||||
if Danbooru.config.iqdb_hostname_and_port
|
|
||||||
@matches = Iqdb::Server.default.query(3, @download.file_path).matches
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user