Warn if config file contains non-existing paths. Fixes issue #244
This commit is contained in:
parent
3932a25aa2
commit
4989d1f991
@ -70,6 +70,7 @@ static int op_flags;
|
|||||||
#define OPT_n 0x20000
|
#define OPT_n 0x20000
|
||||||
#define OPT_r 0x40000
|
#define OPT_r 0x40000
|
||||||
#define OPT_k 0x80000
|
#define OPT_k 0x80000
|
||||||
|
#define OPT_E 0x100000
|
||||||
|
|
||||||
ReExec *o_reexec;
|
ReExec *o_reexec;
|
||||||
|
|
||||||
@ -251,7 +252,11 @@ static bool createstemdb(RclConfig *config, const string &lang)
|
|||||||
return confindexer->createStemDb(lang);
|
return confindexer->createStemDb(lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checktopdirs(RclConfig *config)
|
// Check that topdir entries are valid (successfull tilde exp + abs
|
||||||
|
// path) or fail.
|
||||||
|
// In addition, topdirs, skippedPaths, daemSkippedPaths entries should
|
||||||
|
// match existing files or directories. Warn if they don't
|
||||||
|
static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
|
||||||
{
|
{
|
||||||
vector<string> tdl;
|
vector<string> tdl;
|
||||||
if (!config->getConfParam("topdirs", &tdl)) {
|
if (!config->getConfParam("topdirs", &tdl)) {
|
||||||
@ -274,6 +279,27 @@ static bool checktopdirs(RclConfig *config)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (access(it->c_str(), 0) < 0) {
|
||||||
|
nonexist.push_back(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config->getConfParam("skippedPaths", &tdl)) {
|
||||||
|
for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
|
||||||
|
*it = path_tildexpand(*it);
|
||||||
|
if (access(it->c_str(), 0) < 0) {
|
||||||
|
nonexist.push_back(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config->getConfParam("daemSkippedPaths", &tdl)) {
|
||||||
|
for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
|
||||||
|
*it = path_tildexpand(*it);
|
||||||
|
if (access(it->c_str(), 0) < 0) {
|
||||||
|
nonexist.push_back(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -311,6 +337,8 @@ static const char usage [] =
|
|||||||
" List available stemming languages\n"
|
" List available stemming languages\n"
|
||||||
"recollindex -s <lang>\n"
|
"recollindex -s <lang>\n"
|
||||||
" Build stem database for additional language <lang>\n"
|
" Build stem database for additional language <lang>\n"
|
||||||
|
"recollindex -E\n"
|
||||||
|
" Check configuration file for topdirs and other paths existence\n"
|
||||||
#ifdef FUTURE_IMPROVEMENT
|
#ifdef FUTURE_IMPROVEMENT
|
||||||
"recollindex -W\n"
|
"recollindex -W\n"
|
||||||
" Process the Web queue\n"
|
" Process the Web queue\n"
|
||||||
@ -377,6 +405,7 @@ int main(int argc, char **argv)
|
|||||||
case 'C': op_flags |= OPT_C; break;
|
case 'C': op_flags |= OPT_C; break;
|
||||||
case 'D': op_flags |= OPT_D; break;
|
case 'D': op_flags |= OPT_D; break;
|
||||||
#endif
|
#endif
|
||||||
|
case 'E': op_flags |= OPT_E; break;
|
||||||
case 'e': op_flags |= OPT_e; break;
|
case 'e': op_flags |= OPT_e; break;
|
||||||
case 'f': op_flags |= OPT_f; break;
|
case 'f': op_flags |= OPT_f; break;
|
||||||
case 'h': op_flags |= OPT_h; break;
|
case 'h': op_flags |= OPT_h; break;
|
||||||
@ -415,7 +444,9 @@ int main(int argc, char **argv)
|
|||||||
Usage();
|
Usage();
|
||||||
if ((op_flags & OPT_Z) && (op_flags & (OPT_m)))
|
if ((op_flags & OPT_Z) && (op_flags & (OPT_m)))
|
||||||
Usage();
|
Usage();
|
||||||
|
if ((op_flags & OPT_E) && (op_flags & ~OPT_E)) {
|
||||||
|
Usage();
|
||||||
|
}
|
||||||
string reason;
|
string reason;
|
||||||
RclInitFlags flags = (op_flags & OPT_m) && !(op_flags&OPT_D) ?
|
RclInitFlags flags = (op_flags & OPT_m) && !(op_flags&OPT_D) ?
|
||||||
RCLINIT_DAEMON : RCLINIT_NONE;
|
RCLINIT_DAEMON : RCLINIT_NONE;
|
||||||
@ -426,9 +457,25 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
o_reexec->atexit(cleanup);
|
o_reexec->atexit(cleanup);
|
||||||
|
|
||||||
if (!checktopdirs(config))
|
vector<string> nonexist;
|
||||||
|
if (!checktopdirs(config, nonexist))
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
|
if (nonexist.size()) {
|
||||||
|
ostream& out = (op_flags & OPT_E) ? cout : cerr;
|
||||||
|
if (!(op_flags & OPT_E)) {
|
||||||
|
cerr << "Warning: invalid paths in topdirs, skippedPaths or "
|
||||||
|
"daemSkippedPaths:\n";
|
||||||
|
}
|
||||||
|
for (vector<string>::const_iterator it = nonexist.begin();
|
||||||
|
it != nonexist.end(); it++) {
|
||||||
|
out << *it << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((op_flags & OPT_E)) {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
string rundir;
|
string rundir;
|
||||||
config->getConfParam("idxrundir", rundir);
|
config->getConfParam("idxrundir", rundir);
|
||||||
if (!rundir.compare("tmp")) {
|
if (!rundir.compare("tmp")) {
|
||||||
|
|||||||
@ -887,6 +887,24 @@ void RclMain::toggleIndexing()
|
|||||||
m_firstIndexing = !theconfig->getMissingHelperDesc(mhd);
|
m_firstIndexing = !theconfig->getMissingHelperDesc(mhd);
|
||||||
|
|
||||||
vector<string> args;
|
vector<string> args;
|
||||||
|
|
||||||
|
string badpaths;
|
||||||
|
args.push_back("recollindex");
|
||||||
|
args.push_back("-E");
|
||||||
|
ExecCmd::backtick(args, badpaths);
|
||||||
|
if (!badpaths.empty()) {
|
||||||
|
int rep =
|
||||||
|
QMessageBox::warning(0, tr("Bad paths"),
|
||||||
|
tr("Bad paths in configuration file:\n") +
|
||||||
|
QString::fromLocal8Bit(badpaths.c_str()),
|
||||||
|
QMessageBox::Ok,
|
||||||
|
QMessageBox::Cancel,
|
||||||
|
QMessageBox::NoButton);
|
||||||
|
if (rep == QMessageBox::Cancel)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
args.clear();
|
||||||
args.push_back("-c");
|
args.push_back("-c");
|
||||||
args.push_back(theconfig->getConfDir());
|
args.push_back(theconfig->getConfDir());
|
||||||
if (fileRetryFailedAction->isChecked())
|
if (fileRetryFailedAction->isChecked())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user