arrange for error info about missing helpers to trickle up to the user
This commit is contained in:
parent
faeb96cb01
commit
33dd17daeb
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.51 2007-02-02 10:12:58 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.52 2007-02-06 18:01:57 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -432,7 +432,7 @@ DbIndexer::processone(const std::string &fn, const struct stat *stp,
|
||||
Rcl::Doc fileDoc;
|
||||
fileDoc.fmtime = ascdate;
|
||||
fileDoc.utf8fn = utf8fn;
|
||||
fileDoc.mimetype = interner.get_mimetype();
|
||||
fileDoc.mimetype = interner.getMimetype();
|
||||
if (!m_db.add(fn, fileDoc, stp))
|
||||
return FsTreeWalker::FtwError;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.25 2007-01-17 13:53:40 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.26 2007-02-06 18:01:58 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -367,8 +367,14 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, string& ipath)
|
||||
if (!m_handlers.back()->next_document()) {
|
||||
Rcl::Doc doc; string ipath;
|
||||
collectIpathAndMT(doc, ipath);
|
||||
LOGERR(("FileInterner::internfile: next_document error [%s%s%s]\n",
|
||||
m_fn.c_str(), ipath.empty()?"":"|", ipath.c_str()));
|
||||
m_reason = m_handlers.back()->get_error();
|
||||
LOGERR(("FileInterner::internfile: next_document error [%s%s%s] %s\n",
|
||||
m_fn.c_str(), ipath.empty()?"":"|", ipath.c_str(),
|
||||
m_reason.c_str()));
|
||||
// If fetching a specific document, this is fatal
|
||||
if (m_forPreview) {
|
||||
return FIError;
|
||||
}
|
||||
popHandler();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _INTERNFILE_H_INCLUDED_
|
||||
#define _INTERNFILE_H_INCLUDED_
|
||||
/* @(#$Id: internfile.h,v 1.11 2007-01-15 13:06:38 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: internfile.h,v 1.12 2007-02-06 18:01:58 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -79,7 +79,7 @@ class FileInterner {
|
||||
Status internfile(Rcl::Doc& doc, string &ipath);
|
||||
|
||||
/** Return the file's mimetype (useful for container files) */
|
||||
const string& get_mimetype() {return m_mimetype;}
|
||||
const string& getMimetype() {return m_mimetype;}
|
||||
|
||||
/** We normally always return text/plain data. A caller can request
|
||||
* that we stop conversion at the native document type (ie: text/html)
|
||||
@ -90,6 +90,8 @@ class FileInterner {
|
||||
static bool idocTempFile(TempFile& temp, RclConfig *cnf, const string& fn,
|
||||
const string& ipath, const string& mtype);
|
||||
|
||||
const string& getReason() const {return m_reason;}
|
||||
|
||||
private:
|
||||
static const unsigned int MAXHANDLERS = 20;
|
||||
RclConfig *m_cfg;
|
||||
@ -100,9 +102,14 @@ class FileInterner {
|
||||
// m_tdir and m_tfile are used only for decompressing input file if needed
|
||||
const string& m_tdir;
|
||||
string m_tfile;
|
||||
// Filter stack, path to the current document from which we're
|
||||
// fetching subdocs
|
||||
vector<Dijon::Filter*> m_handlers;
|
||||
// Temporary files used for decoding the current stack
|
||||
bool m_tmpflgs[MAXHANDLERS];
|
||||
vector<TempFile> m_tempfiles;
|
||||
// Error data if any
|
||||
string m_reason;
|
||||
|
||||
void tmpcleanup();
|
||||
bool dijontorcl(Rcl::Doc&);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: mh_exec.cpp,v 1.8 2006-12-15 12:40:02 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: mh_exec.cpp,v 1.9 2007-02-06 18:01:58 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -45,6 +45,7 @@ bool MimeHandlerExec::next_document()
|
||||
if (params.empty()) {
|
||||
// Hu ho
|
||||
LOGERR(("MimeHandlerExec::mkDoc: empty params\n"));
|
||||
m_reason = "RECFILTERROR BADCONFIG";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,6 +59,7 @@ bool MimeHandlerExec::next_document()
|
||||
|
||||
// Execute command and store the result text, which is supposedly html
|
||||
string& html = m_metaData["content"];
|
||||
html.erase();
|
||||
ExecCmd mexec;
|
||||
MEAdv adv;
|
||||
mexec.setAdvise(&adv);
|
||||
@ -67,6 +69,10 @@ bool MimeHandlerExec::next_document()
|
||||
if (status) {
|
||||
LOGERR(("MimeHandlerExec: command status 0x%x: %s\n",
|
||||
status, cmd.c_str()));
|
||||
// If the output string begins with RECFILTERROR, then it's
|
||||
// interpretable error information
|
||||
if (html.find("RECFILTERROR") == 0)
|
||||
m_reason = html;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.14 2007-01-19 15:22:50 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.15 2007-02-06 18:01:58 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -443,6 +443,7 @@ class LoadThread : public QThread {
|
||||
string tmpdir;
|
||||
int loglevel;
|
||||
public:
|
||||
string reason;
|
||||
LoadThread(int *stp, Rcl::Doc *odoc, string fn, string ip, string *mt)
|
||||
: statusp(stp), out(odoc), filename(fn), ipath(ip), mtype(mt)
|
||||
{
|
||||
@ -456,7 +457,6 @@ class LoadThread : public QThread {
|
||||
}
|
||||
virtual void run() {
|
||||
DebugLog::getdbl()->setloglevel(loglevel);
|
||||
string reason;
|
||||
if (!maketmpdir(tmpdir, reason)) {
|
||||
QMessageBox::critical(0, "Recoll",
|
||||
Preview::tr("Cannot create temporary directory"));
|
||||
@ -485,7 +485,8 @@ class LoadThread : public QThread {
|
||||
// a search term of course.
|
||||
*statusp = 0;
|
||||
} else {
|
||||
out->mimetype = interner.get_mimetype();
|
||||
out->mimetype = interner.getMimetype();
|
||||
reason = interner.getReason();
|
||||
*statusp = -1;
|
||||
}
|
||||
} catch (CancelExcept) {
|
||||
@ -586,9 +587,25 @@ bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc,
|
||||
if (cancel)
|
||||
return false;
|
||||
if (status != 0) {
|
||||
QString explain;
|
||||
if (lthr.reason.find("RECFILTERROR") == 0) {
|
||||
list<string> lerr;
|
||||
stringToStrings(lthr.reason, lerr);
|
||||
if (lerr.size() > 2) {
|
||||
list<string>::iterator it = lerr.begin();
|
||||
it++;
|
||||
if (*it == "HELPERNOTFOUND") {
|
||||
it++;
|
||||
explain = QString::fromAscii("<br>") +
|
||||
tr("Missing helper program: ") +
|
||||
QString::fromLocal8Bit(it->c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("Can't turn doc into internal rep for ") +
|
||||
fdoc.mimetype.c_str());
|
||||
tr("Can't turn doc into internal "
|
||||
"representation for ") +
|
||||
fdoc.mimetype.c_str() + explain);
|
||||
return false;
|
||||
}
|
||||
// Reset config just in case.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user