improve message printed for aspell dictionary creation error
This commit is contained in:
parent
f025ff33dd
commit
4a17bac9e3
@ -297,22 +297,47 @@ bool Aspell::buildDict(Rcl::Db &db, string &reason)
|
|||||||
args.push_back("create");
|
args.push_back("create");
|
||||||
args.push_back("master");
|
args.push_back("master");
|
||||||
args.push_back(dicPath());
|
args.push_back(dicPath());
|
||||||
aspell.setStderr("/dev/null");
|
|
||||||
|
// Have to disable stderr, as numerous messages about bad strings are
|
||||||
|
// printed. We'd like to keep errors about missing databases though, so
|
||||||
|
// make it configurable for diags
|
||||||
|
bool keepStderr = false;
|
||||||
|
m_config->getConfParam("aspellKeepStderr", &keepStderr);
|
||||||
|
if (!keepStderr)
|
||||||
|
aspell.setStderr("/dev/null");
|
||||||
|
|
||||||
Rcl::TermIter *tit = db.termWalkOpen();
|
Rcl::TermIter *tit = db.termWalkOpen();
|
||||||
if (tit == 0) {
|
if (tit == 0) {
|
||||||
reason = "termWalkOpen failed\n";
|
reason = "termWalkOpen failed\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string termbuf;
|
string termbuf;
|
||||||
AspExecPv pv(&termbuf, tit, db);
|
AspExecPv pv(&termbuf, tit, db);
|
||||||
aspell.setProvide(&pv);
|
aspell.setProvide(&pv);
|
||||||
|
|
||||||
if (aspell.doexec(m_data->m_exec, args, &termbuf)) {
|
if (aspell.doexec(m_data->m_exec, args, &termbuf)) {
|
||||||
reason = string("aspell dictionary creation command failed.\n"
|
ExecCmd cmd;
|
||||||
"One possible reason might be missing language "
|
args.clear();
|
||||||
"data files for lang = ") + m_lang;
|
args.push_back("dicts");
|
||||||
|
string dicts;
|
||||||
|
bool hasdict = false;
|
||||||
|
if (!cmd.doexec(m_data->m_exec, args, 0, &dicts)) {
|
||||||
|
vector<string> vdicts;
|
||||||
|
stringToTokens(dicts, vdicts, "\n\r\t ");
|
||||||
|
if (find(vdicts.begin(), vdicts.end(), m_lang) != vdicts.end()) {
|
||||||
|
hasdict = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasdict)
|
||||||
|
reason = string(
|
||||||
|
"\naspell dictionary creation command failed. Reason unknown.\n"
|
||||||
|
"Try to set aspellKeepStderr = 1 in recoll.conf, and execute \n"
|
||||||
|
"the indexing command in a terminal to see the aspell "
|
||||||
|
"diagnostic output.\n");
|
||||||
|
else
|
||||||
|
reason = string("aspell dictionary creation command failed.\n"
|
||||||
|
"One possible reason might be missing language "
|
||||||
|
"data files for lang = ") + m_lang;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
db.termWalkClose(tit);
|
db.termWalkClose(tit);
|
||||||
|
|||||||
@ -27,6 +27,8 @@
|
|||||||
#include "rcldoc.h"
|
#include "rcldoc.h"
|
||||||
#include "stoplist.h"
|
#include "stoplist.h"
|
||||||
#include "rclconfig.h"
|
#include "rclconfig.h"
|
||||||
|
#include "utf8iter.h"
|
||||||
|
#include "textsplit.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@ -192,6 +194,9 @@ class Db {
|
|||||||
return false;
|
return false;
|
||||||
if (has_prefix(term))
|
if (has_prefix(term))
|
||||||
return false;
|
return false;
|
||||||
|
Utf8Iter u8i(term);
|
||||||
|
if (TextSplit::isCJK(*u8i))
|
||||||
|
return false;
|
||||||
if (term.find_first_of(" !\"#$%&()*+,-./0123456789:;<=>?@[\\]^_`{|}~")
|
if (term.find_first_of(" !\"#$%&()*+,-./0123456789:;<=>?@[\\]^_`{|}~")
|
||||||
!= string::npos)
|
!= string::npos)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user