From 99fb4e60ab9081fc061a12e812edc36631a4a914 Mon Sep 17 00:00:00 2001 From: Toks Date: Fri, 7 Nov 2014 02:39:15 -0500 Subject: [PATCH] Fix iqdb file was getting deleted before it got used --- app/controllers/iqdb_queries_controller.rb | 3 +-- app/logical/iqdb/download.rb | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/controllers/iqdb_queries_controller.rb b/app/controllers/iqdb_queries_controller.rb index 00127d0c4..62d07d726 100644 --- a/app/controllers/iqdb_queries_controller.rb +++ b/app/controllers/iqdb_queries_controller.rb @@ -19,8 +19,7 @@ class IqdbQueriesController < ApplicationController protected def create_by_url @download = Iqdb::Download.new(params[:url]) - @download.download_from_source - @download.find_similar + @download.download_and_find_similar @results = @download.matches render :layout => false, :action => "create_by_url" end diff --git a/app/logical/iqdb/download.rb b/app/logical/iqdb/download.rb index fb81e3db1..e6d1de49a 100644 --- a/app/logical/iqdb/download.rb +++ b/app/logical/iqdb/download.rb @@ -6,19 +6,17 @@ module Iqdb @source = source end - def download_from_source + 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 - - def find_similar - if Danbooru.config.iqdb_hostname_and_port - @matches = Iqdb::Server.default.query(3, @download.file_path).matches - end - end end end