From d47f57850ee45355d74804e935878cd8a5f6ee01 Mon Sep 17 00:00:00 2001 From: Donovan Daniels Date: Sun, 13 Oct 2024 03:56:39 -0500 Subject: [PATCH] fix it better --- app/controllers/yiff_rest/api_v2/images_controller.rb | 3 ++- app/logical/iqdb.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/yiff_rest/api_v2/images_controller.rb b/app/controllers/yiff_rest/api_v2/images_controller.rb index 9369e39..7f0cf61 100644 --- a/app/controllers/yiff_rest/api_v2/images_controller.rb +++ b/app/controllers/yiff_rest/api_v2/images_controller.rb @@ -63,6 +63,7 @@ module YiffRest def query_iqdb @sp = search_iqdb_params + @sp[:image_id] ||= @sp[:md5] @sc = (@sp[:score_cutoff].presence || 60).to_i if @sp[:file].present? @results = Iqdb.query_file(@sp[:file], @sc) @@ -92,7 +93,7 @@ module YiffRest end def search_iqdb_params - permit_search_params(%i[file url image_id score_cutoff]) + permit_search_params(%i[file url image_id md5 score_cutoff]) end def create_params diff --git a/app/logical/iqdb.rb b/app/logical/iqdb.rb index cf5f881..6047eaa 100644 --- a/app/logical/iqdb.rb +++ b/app/logical/iqdb.rb @@ -54,13 +54,13 @@ module Iqdb end def query_file(file, score_cutoff) - Tempfile.open("yiffy2-#{file.md5}") do |tempfile| + Tempfile.open("yiffy2-queryfile") do |tempfile| file.binmode tempfile.binmode tempfile.write(file.read) tempfile.rewind thumb = generate_thumbnail(tempfile.path) - raise(Error, "failed to generate thumb for #{file.md5}") unless thumb + raise(Error, "failed to generate thumb for file") unless thumb response = make_request("/query", :post, get_channels_data(thumb)) raise(Error, "iqdb request failed") if response.status != 200