Indicate log location in some indexer error messages which will be displayed in the GUI

This commit is contained in:
Jean-Francois Dockes 2020-11-19 11:16:51 +01:00
parent 3e72a11932
commit 8111320a22
2 changed files with 58 additions and 47 deletions

View File

@ -156,6 +156,13 @@ 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) {
@ -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;
}

View File

@ -397,6 +397,7 @@ static bool checktopdirs(RclConfig *config, vector<string>& 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<string>& nonexist)
}
if (!path_exists(dir)) {
nonexist.push_back(dir);
} else {
onegood = true;
}
}
topdirs_state(o_topdirs_emptiness);
@ -418,7 +421,7 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
// We'd like to check skippedPaths too, but these are wildcard
// exprs, so reasonably can't
return true;
return onegood;
}
@ -708,7 +711,8 @@ int main(int argc, char *argv[])
vector<string> 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);
}