From b771eb72869226370227d1921515ded57fd52a48 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 9 Jul 2012 19:13:16 +0000 Subject: [PATCH] * non-strict mode: auto-pick first and only result even if it seems to be a bad match --- source/net/sourceforge/filebot/cli/CmdlineOperations.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/net/sourceforge/filebot/cli/CmdlineOperations.java b/source/net/sourceforge/filebot/cli/CmdlineOperations.java index d65f250e..a0143fea 100644 --- a/source/net/sourceforge/filebot/cli/CmdlineOperations.java +++ b/source/net/sourceforge/filebot/cli/CmdlineOperations.java @@ -771,10 +771,15 @@ public class CmdlineOperations implements CmdlineInterface { } - public List selectSearchResult(String query, Iterable searchResults, boolean strict) throws Exception { + public List selectSearchResult(String query, Collection searchResults, boolean strict) throws Exception { List probableMatches = findProbableMatches(query, searchResults, strict); if (probableMatches.isEmpty() || (strict && probableMatches.size() != 1)) { + // allow single search results to just pass through in non-strict mode even if match confidence is low + if (searchResults.size() == 1 && !strict) { + return new ArrayList(searchResults); + } + throw new Exception("Failed to auto-select search result: " + searchResults); }