diff --git a/src/index/recollindex.cpp b/src/index/recollindex.cpp index 3f7dd701..f79cf4a1 100644 --- a/src/index/recollindex.cpp +++ b/src/index/recollindex.cpp @@ -70,6 +70,7 @@ static int op_flags; #define OPT_n 0x20000 #define OPT_r 0x40000 #define OPT_k 0x80000 +#define OPT_E 0x100000 ReExec *o_reexec; @@ -251,7 +252,11 @@ static bool createstemdb(RclConfig *config, const string &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& nonexist) { vector tdl; if (!config->getConfParam("topdirs", &tdl)) { @@ -274,6 +279,27 @@ static bool checktopdirs(RclConfig *config) } return false; } + if (access(it->c_str(), 0) < 0) { + nonexist.push_back(*it); + } + } + + if (config->getConfParam("skippedPaths", &tdl)) { + for (vector::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::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; } @@ -311,6 +337,8 @@ static const char usage [] = " List available stemming languages\n" "recollindex -s \n" " Build stem database for additional language \n" +"recollindex -E\n" +" Check configuration file for topdirs and other paths existence\n" #ifdef FUTURE_IMPROVEMENT "recollindex -W\n" " Process the Web queue\n" @@ -377,6 +405,7 @@ int main(int argc, char **argv) case 'C': op_flags |= OPT_C; break; case 'D': op_flags |= OPT_D; break; #endif + case 'E': op_flags |= OPT_E; break; case 'e': op_flags |= OPT_e; break; case 'f': op_flags |= OPT_f; break; case 'h': op_flags |= OPT_h; break; @@ -415,7 +444,9 @@ int main(int argc, char **argv) Usage(); if ((op_flags & OPT_Z) && (op_flags & (OPT_m))) Usage(); - + if ((op_flags & OPT_E) && (op_flags & ~OPT_E)) { + Usage(); + } string reason; RclInitFlags flags = (op_flags & OPT_m) && !(op_flags&OPT_D) ? RCLINIT_DAEMON : RCLINIT_NONE; @@ -426,9 +457,25 @@ int main(int argc, char **argv) } o_reexec->atexit(cleanup); - if (!checktopdirs(config)) + vector nonexist; + if (!checktopdirs(config, nonexist)) 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::const_iterator it = nonexist.begin(); + it != nonexist.end(); it++) { + out << *it << endl; + } + } + if ((op_flags & OPT_E)) { + exit(0); + } + string rundir; config->getConfParam("idxrundir", rundir); if (!rundir.compare("tmp")) { diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 487cbbe3..baee8058 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -887,6 +887,24 @@ void RclMain::toggleIndexing() m_firstIndexing = !theconfig->getMissingHelperDesc(mhd); vector 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(theconfig->getConfDir()); if (fileRetryFailedAction->isChecked())