From d3d27dcd2113d672c7fdb8a6b4535de5996cb11c Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 31 Mar 2021 15:29:42 +0200 Subject: [PATCH] Ensure that the missing helper is listed in the log for all affected documents --- src/internfile/mh_exec.cpp | 18 +++++++----------- src/internfile/mh_exec.h | 1 + src/internfile/mh_execm.cpp | 16 ++++++++++------ 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/internfile/mh_exec.cpp b/src/internfile/mh_exec.cpp index 302558ae..396cea98 100644 --- a/src/internfile/mh_exec.cpp +++ b/src/internfile/mh_exec.cpp @@ -20,8 +20,6 @@ #include #include "safesyswait.h" -#include - #include "cstr.h" #include "execmd.h" #include "mh_exec.h" @@ -131,6 +129,7 @@ bool MimeHandlerExec::next_document() m_havedoc = false; if (missingHelper) { LOGDEB("MimeHandlerExec::next_document(): helper known missing\n"); + m_reason = whatHelper; return false; } @@ -186,21 +185,18 @@ bool MimeHandlerExec::next_document() // missing cmd. missingHelper = true; m_reason = string("RECFILTERROR HELPERNOTFOUND ") + cmd; + whatHelper = m_reason; } else if (output.find("RECFILTERROR") == 0) { // If the output string begins with RECFILTERROR, then it's // interpretable error information out from a recoll script m_reason = output; - list lerr; - stringToStrings(output, lerr); - if (lerr.size() > 2) { - list::iterator it = lerr.begin(); - it++; - if (*it == "HELPERNOTFOUND") { - // No use trying again and again to execute this filter, - // it won't work. + std::string::size_type pos; + if ((pos = output.find("RECFILTERROR ")) == 0) { + if (output.find("HELPERNOTFOUND") != string::npos) { missingHelper = true; + whatHelper = output.substr(pos); } - } + } } return false; } diff --git a/src/internfile/mh_exec.h b/src/internfile/mh_exec.h index bc325730..c74d0e96 100644 --- a/src/internfile/mh_exec.h +++ b/src/internfile/mh_exec.h @@ -63,6 +63,7 @@ public: // line option. std::string cfgFilterOutputCharset; bool missingHelper{false}; + std::string whatHelper; // Resource management values // The filtermaxseconds default is set in the constructor by diff --git a/src/internfile/mh_execm.cpp b/src/internfile/mh_execm.cpp index bf2f4b7d..59bf83e5 100644 --- a/src/internfile/mh_execm.cpp +++ b/src/internfile/mh_execm.cpp @@ -17,10 +17,10 @@ #include "autoconfig.h" #include - +#include +#include "safesyswait.h" #include #include -using namespace std; #include "cstr.h" #include "mh_execm.h" @@ -34,8 +34,7 @@ using namespace std; #include "idfile.h" #include "rclutil.h" -#include -#include "safesyswait.h" +using namespace std; bool MimeHandlerExecMultiple::startCmd() { @@ -75,6 +74,7 @@ bool MimeHandlerExecMultiple::startCmd() if (m_cmd.startExec(cmd, myparams, 1, 1) < 0) { m_reason = string("RECFILTERROR HELPERNOTFOUND ") + cmd; missingHelper = true; + whatHelper = cmd; return false; } return true; @@ -109,10 +109,13 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data) // Filters will sometimes abort before entering the real protocol, ie if // a module can't be loaded. Check the special filter error first word: - if (ibuf.find("RECFILTERROR ") == 0) { + std::string::size_type pos; + if ((pos = ibuf.find("RECFILTERROR ")) == 0) { m_reason = ibuf; - if (ibuf.find("HELPERNOTFOUND") != string::npos) + if (ibuf.find("HELPERNOTFOUND") != string::npos) { missingHelper = true; + whatHelper = ibuf.substr(pos); + } return false; } @@ -168,6 +171,7 @@ bool MimeHandlerExecMultiple::next_document() if (missingHelper) { LOGDEB("MHExecMultiple::next_document(): helper known missing\n"); + m_reason = whatHelper; return false; }