GUI: when opening the index, discriminate errors on the main index from errors on external ones, to avoid starting the initial indexing dialog in the latter case
This commit is contained in:
+6
-2
@@ -72,7 +72,7 @@ void startManual(const string& helpindex)
|
||||
mainWindow->startManual(helpindex);
|
||||
}
|
||||
|
||||
bool maybeOpenDb(string &reason, bool force)
|
||||
bool maybeOpenDb(string &reason, bool force, bool *maindberror)
|
||||
{
|
||||
if (!rcldb) {
|
||||
reason = "Internal error: db not created";
|
||||
@@ -87,9 +87,13 @@ bool maybeOpenDb(string &reason, bool force)
|
||||
LOGDEB(("main: adding [%s]\n", it->c_str()));
|
||||
rcldb->addQueryDb(*it);
|
||||
}
|
||||
if (!rcldb->isopen() && !rcldb->open(Rcl::Db::DbRO)) {
|
||||
Rcl::Db::OpenError error;
|
||||
if (!rcldb->isopen() && !rcldb->open(Rcl::Db::DbRO, &error)) {
|
||||
reason = "Could not open database in " +
|
||||
theconfig->getDbDir() + " wait for indexing to complete?";
|
||||
if (maindberror) {
|
||||
*maindberror = (error == Rcl::Db::DbOpenMainDb) ? true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
rcldb->setAbstractParams(-1, prefs.syntAbsLen, prefs.syntAbsCtx);
|
||||
|
||||
+22
-16
@@ -345,25 +345,31 @@ void RclMain::initDbOpen()
|
||||
bool needindexconfig = false;
|
||||
bool nodb = false;
|
||||
string reason;
|
||||
if (!maybeOpenDb(reason)) {
|
||||
bool maindberror;
|
||||
if (!maybeOpenDb(reason, true, &maindberror)) {
|
||||
nodb = true;
|
||||
switch (QMessageBox::
|
||||
question
|
||||
(this, "Recoll",
|
||||
qApp->translate("Main", "Could not open database in ") +
|
||||
QString::fromLocal8Bit(theconfig->getDbDir().c_str()) +
|
||||
qApp->translate("Main",
|
||||
".\n"
|
||||
"Click Cancel if you want to edit the configuration file before indexing starts, or Ok to let it proceed."),
|
||||
"Ok", "Cancel", 0, 0)) {
|
||||
if (maindberror) {
|
||||
switch (QMessageBox::
|
||||
question
|
||||
(this, "Recoll",
|
||||
qApp->translate("Main", "Could not open database in ") +
|
||||
QString::fromLocal8Bit(theconfig->getDbDir().c_str()) +
|
||||
qApp->translate("Main",
|
||||
".\n"
|
||||
"Click Cancel if you want to edit the configuration file before indexing starts, or Ok to let it proceed."),
|
||||
"Ok", "Cancel", 0, 0)) {
|
||||
|
||||
case 0: // Ok: indexing is going to start.
|
||||
start_indexing(true);
|
||||
break;
|
||||
case 0: // Ok: indexing is going to start.
|
||||
start_indexing(true);
|
||||
break;
|
||||
|
||||
case 1: // Cancel
|
||||
needindexconfig = true;
|
||||
break;
|
||||
case 1: // Cancel
|
||||
needindexconfig = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("Could not open external index. Db not open. Check external indexes list."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -26,7 +26,8 @@
|
||||
// Misc declarations in need of sharing between the UI files
|
||||
|
||||
// Open the database if needed. We now force a close/open by default
|
||||
extern bool maybeOpenDb(std::string &reason, bool force = true);
|
||||
extern bool maybeOpenDb(std::string &reason, bool force = true,
|
||||
bool *maindberror = 0);
|
||||
|
||||
/** Retrieve configured stemming languages */
|
||||
bool getStemLangs(list<string>& langs);
|
||||
|
||||
+12
-2
@@ -534,8 +534,11 @@ list<string> Db::getStemmerNames()
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Db::open(OpenMode mode)
|
||||
bool Db::open(OpenMode mode, OpenError *error)
|
||||
{
|
||||
if (error)
|
||||
*error = DbOpenMainDb;
|
||||
|
||||
if (m_ndb == 0 || m_config == 0) {
|
||||
m_reason = "Null configuration or Xapian Db";
|
||||
return false;
|
||||
@@ -586,12 +589,17 @@ bool Db::open(OpenMode mode)
|
||||
m_ndb->xrdb = Xapian::Database(dir);
|
||||
for (list<string>::iterator it = m_extraDbs.begin();
|
||||
it != m_extraDbs.end(); it++) {
|
||||
if (error)
|
||||
*error = DbOpenExtraDb;
|
||||
LOGDEB(("Db::Open: adding query db [%s]\n", it->c_str()));
|
||||
// Used to be non-fatal (1.13 and older) but I can't see why
|
||||
// An error here used to be non-fatal (1.13 and older)
|
||||
// but I can't see why
|
||||
m_ndb->xrdb.add_database(Xapian::Database(*it));
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (error)
|
||||
*error = DbOpenMainDb;
|
||||
|
||||
// Check index format version. Must not try to check a just created or
|
||||
// truncated db
|
||||
@@ -608,6 +616,8 @@ bool Db::open(OpenMode mode)
|
||||
m_mode = mode;
|
||||
m_ndb->m_isopen = true;
|
||||
m_basedir = dir;
|
||||
if (error)
|
||||
*error = DbOpenNoError;
|
||||
return true;
|
||||
} XCATCHERROR(ermsg);
|
||||
|
||||
|
||||
+2
-1
@@ -95,7 +95,8 @@ class Db {
|
||||
~Db();
|
||||
|
||||
enum OpenMode {DbRO, DbUpd, DbTrunc};
|
||||
bool open(OpenMode mode);
|
||||
enum OpenError {DbOpenNoError, DbOpenMainDb, DbOpenExtraDb};
|
||||
bool open(OpenMode mode, OpenError *error = 0);
|
||||
bool close();
|
||||
bool isopen();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user