From 8111320a22ea8c81978545e5d4ad1ba5d725108f Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 19 Nov 2020 11:16:51 +0100 Subject: [PATCH] Indicate log location in some indexer error messages which will be displayed in the GUI --- src/index/indexer.cpp | 17 +++++--- src/index/recollindex.cpp | 88 ++++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/src/index/indexer.cpp b/src/index/indexer.cpp index 5d646020..8b0aa076 100644 --- a/src/index/indexer.cpp +++ b/src/index/indexer.cpp @@ -156,7 +156,14 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags) addIdxReason("indexer", m_db.getReason()); return false; } - + std::string logloc; + if (Logger::getTheLog()->logisstderr()) { + logloc = "program error output."; + } else { + logloc = std::string(" log in ") + + Logger::getTheLog()->getlogfilename() + "."; + } + m_config->setKeyDir(cstr_null); if (typestorun & IxTFs) { if (runFirstIndexing()) { @@ -168,7 +175,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags) if (stopindexing) { addIdxReason("indexer", "Indexing was interrupted."); } else { - addIdxReason("indexer", "Index creation failed. See log."); + addIdxReason("indexer", "Index creation failed. See" + logloc); } m_db.close(); return false; @@ -181,7 +188,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags) m_webindexer = new WebQueueIndexer(m_config, &m_db, m_updater); if (!m_webindexer || !m_webindexer->index()) { m_db.close(); - addIdxReason("indexer", "Web index creation failed. See log"); + addIdxReason("indexer", "Web index creation failed. See" + logloc); return false; } } @@ -191,7 +198,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags) // filesystem anymore. Only if all *configured* indexers ran. if (m_updater && !m_updater->update(DbIxStatus::DBIXS_PURGE, "")) { m_db.close(); - addIdxReason("indexer", "Index purge failed. See log"); + addIdxReason("indexer", "Index purge failed. See" + logloc); return false; } m_db.purge(); @@ -205,7 +212,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags) if (!m_db.close()) { LOGERR("ConfIndexer::index: error closing database in " << m_config->getDbDir() << "\n"); - addIdxReason("indexer", "Index close/flush failed. See log"); + addIdxReason("indexer", "Index close/flush failed. See" +logloc); return false; } diff --git a/src/index/recollindex.cpp b/src/index/recollindex.cpp index d869b618..82a758dc 100644 --- a/src/index/recollindex.cpp +++ b/src/index/recollindex.cpp @@ -396,7 +396,8 @@ static bool checktopdirs(RclConfig *config, vector& nonexist) } } } - + + bool onegood{false}; for (auto& dir : o_topdirs) { dir = path_tildexpand(dir); if (!dir.size() || !path_isabsolute(dir)) { @@ -411,6 +412,8 @@ static bool checktopdirs(RclConfig *config, vector& nonexist) } if (!path_exists(dir)) { nonexist.push_back(dir); + } else { + onegood = true; } } topdirs_state(o_topdirs_emptiness); @@ -418,60 +421,60 @@ static bool checktopdirs(RclConfig *config, vector& nonexist) // We'd like to check skippedPaths too, but these are wildcard // exprs, so reasonably can't - return true; + return onegood; } string thisprog; static const char usage [] = - "\n" - "recollindex [-h] \n" - " Print help\n" - "recollindex [-z|-Z] [-k]\n" - " Index everything according to configuration file\n" - " -z : reset database before starting indexing\n" - " -Z : in place reset: consider all documents as changed. Can also\n" - " be combined with -i or -r but not -m\n" - " -k : retry files on which we previously failed\n" +"\n" +"recollindex [-h] \n" +" Print help\n" +"recollindex [-z|-Z] [-k]\n" +" Index everything according to configuration file\n" +" -z : reset database before starting indexing\n" +" -Z : in place reset: consider all documents as changed. Can also\n" +" be combined with -i or -r but not -m\n" +" -k : retry files on which we previously failed\n" #ifdef RCL_MONITOR - "recollindex -m [-w ] -x [-D] [-C]\n" - " Perform real time indexing. Don't become a daemon if -D is set.\n" - " -w sets number of seconds to wait before starting.\n" - " -C disables monitoring config for changes/reexecuting.\n" - " -n disables initial incremental indexing (!and purge!).\n" +"recollindex -m [-w ] -x [-D] [-C]\n" +" Perform real time indexing. Don't become a daemon if -D is set.\n" +" -w sets number of seconds to wait before starting.\n" +" -C disables monitoring config for changes/reexecuting.\n" +" -n disables initial incremental indexing (!and purge!).\n" #ifndef DISABLE_X11MON - " -x disables exit on end of x11 session\n" +" -x disables exit on end of x11 session\n" #endif /* DISABLE_X11MON */ #endif /* RCL_MONITOR */ - "recollindex -e []\n" - " Purge data for individual files. No stem database updates.\n" - " Reads paths on stdin if none is given as argument.\n" - "recollindex -i [-f] [-Z] []\n" - " Index individual files. No database purge or stem database updates\n" - " Will read paths on stdin if none is given as argument\n" - " -f : ignore skippedPaths and skippedNames while doing this\n" - "recollindex -r [-K] [-f] [-Z] [-p pattern] \n" - " Recursive partial reindex. \n" - " -p : filter file names, multiple instances are allowed, e.g.: \n" - " -p *.odt -p *.pdf\n" - " -K : skip previously failed files (they are retried by default)\n" - "recollindex -l\n" - " 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" +"recollindex -e []\n" +" Purge data for individual files. No stem database updates.\n" +" Reads paths on stdin if none is given as argument.\n" +"recollindex -i [-f] [-Z] []\n" +" Index individual files. No database purge or stem database updates\n" +" Will read paths on stdin if none is given as argument\n" +" -f : ignore skippedPaths and skippedNames while doing this\n" +"recollindex -r [-K] [-f] [-Z] [-p pattern] \n" +" Recursive partial reindex. \n" +" -p : filter file names, multiple instances are allowed, e.g.: \n" +" -p *.odt -p *.pdf\n" +" -K : skip previously failed files (they are retried by default)\n" +"recollindex -l\n" +" 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" +"recollindex -W\n" +" Process the Web queue\n" #endif #ifdef RCL_USE_ASPELL - "recollindex -S\n" - " Build aspell spelling dictionary.>\n" +"recollindex -S\n" +" Build aspell spelling dictionary.>\n" #endif - "Common options:\n" - " -c : specify config directory, overriding $RECOLL_CONFDIR\n" +"Common options:\n" +" -c : specify config directory, overriding $RECOLL_CONFDIR\n" ; static void Usage() @@ -708,7 +711,8 @@ int main(int argc, char *argv[]) vector nonexist; if (!checktopdirs(config, nonexist)) { - addIdxReason("init", "topdirs not set"); + std::cerr << "topdirs not set or only contains invalid paths.\n"; + addIdxReason("init", "topdirs not set or only contains invalid paths."); flushIdxReasons(); exit(1); }