From 4e8cc666f090df4ddf3631ff0dd67ab1d49bf373 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 2 Jun 2022 12:08:32 +0200 Subject: [PATCH] GUI: try to be more helpful when a main index open error occurs --- src/qtgui/main.cpp | 3 +-- src/qtgui/rclmain_w.cpp | 21 ++++++++++++++------- src/rcldb/rclterms.cpp | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 216db41d..89bd9e0c 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -115,8 +115,7 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror) if (!rcldb->isopen() && !rcldb->open(Rcl::Db::DbRO, &error)) { reason = "Could not open database"; if (maindberror) { - reason += " in " + theconfig->getDbDir() + - " wait for indexing to complete?"; + reason += " in " + theconfig->getDbDir() + " : " + rcldb->getReason(); *maindberror = (error == Rcl::Db::DbOpenMainDb) ? true : false; } return false; diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 57d2fae0..5d99ea67 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -572,13 +572,20 @@ void RclMain::initDbOpen() if (!maybeOpenDb(reason, true, &maindberror)) { nodb = true; if (maindberror) { - FirstIdxDialog fidia(this); - connect(fidia.idxconfCLB, SIGNAL(clicked()), this, SLOT(execIndexConfig())); - connect(fidia.idxschedCLB, SIGNAL(clicked()), this, SLOT(execIndexSched())); - connect(fidia.runidxPB, SIGNAL(clicked()), this, SLOT(rebuildIndex())); - fidia.exec(); - // Don't open adv search or run cmd line search in this case. - return; + if (theconfig && !path_exists(theconfig->getDbDir())) { + FirstIdxDialog fidia(this); + connect(fidia.idxconfCLB, SIGNAL(clicked()), this, SLOT(execIndexConfig())); + connect(fidia.idxschedCLB, SIGNAL(clicked()), this, SLOT(execIndexSched())); + connect(fidia.runidxPB, SIGNAL(clicked()), this, SLOT(rebuildIndex())); + fidia.exec(); + // Don't open adv search or run cmd line search in this case. + return; + } else { + QMessageBox::warning( + 0, "Recoll", tr("Main index open error: ") + u8s2qs(reason) + + tr(". The index may be corrupted. Maybe try to run xapian-check or " + "rebuild the index ?.")); + } } else { QMessageBox::warning(0, "Recoll", tr("Could not open external index. Db not " "open. Check external indexes list.")); diff --git a/src/rcldb/rclterms.cpp b/src/rcldb/rclterms.cpp index c3b7f151..1b98e9c2 100644 --- a/src/rcldb/rclterms.cpp +++ b/src/rcldb/rclterms.cpp @@ -529,7 +529,7 @@ bool Db::dirlist(int depth, std::string& root, std::vector& dirs) break; } if (!m_reason.empty()) { - LOGERR("Db::dirlist: " << m_reason << "\n"); + LOGERR("Db::dirlist: exception while accessing index: " << m_reason << "\n"); return false; }