Ensure that the missing helper is listed in the log for all affected documents

This commit is contained in:
Jean-Francois Dockes 2021-03-31 15:29:42 +02:00
parent 369147e62e
commit d3d27dcd21
3 changed files with 18 additions and 17 deletions

View File

@ -20,8 +20,6 @@
#include <time.h>
#include "safesyswait.h"
#include <list>
#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,19 +185,16 @@ 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<string> lerr;
stringToStrings(output, lerr);
if (lerr.size() > 2) {
list<string>::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);
}
}
}

View File

@ -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

View File

@ -17,10 +17,10 @@
#include "autoconfig.h"
#include <stdio.h>
#include <sys/types.h>
#include "safesyswait.h"
#include <iostream>
#include <sstream>
using namespace std;
#include "cstr.h"
#include "mh_execm.h"
@ -34,8 +34,7 @@ using namespace std;
#include "idfile.h"
#include "rclutil.h"
#include <sys/types.h>
#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;
}