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:
Jean-Francois Dockes 2011-04-29 16:16:04 +02:00
parent eacf71bf99
commit 84d59f18a0
6 changed files with 63 additions and 39 deletions

View File

@ -72,7 +72,7 @@ void startManual(const string& helpindex)
mainWindow->startManual(helpindex); mainWindow->startManual(helpindex);
} }
bool maybeOpenDb(string &reason, bool force) bool maybeOpenDb(string &reason, bool force, bool *maindberror)
{ {
if (!rcldb) { if (!rcldb) {
reason = "Internal error: db not created"; reason = "Internal error: db not created";
@ -87,9 +87,13 @@ bool maybeOpenDb(string &reason, bool force)
LOGDEB(("main: adding [%s]\n", it->c_str())); LOGDEB(("main: adding [%s]\n", it->c_str()));
rcldb->addQueryDb(*it); 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 " + reason = "Could not open database in " +
theconfig->getDbDir() + " wait for indexing to complete?"; theconfig->getDbDir() + " wait for indexing to complete?";
if (maindberror) {
*maindberror = (error == Rcl::Db::DbOpenMainDb) ? true : false;
}
return false; return false;
} }
rcldb->setAbstractParams(-1, prefs.syntAbsLen, prefs.syntAbsCtx); rcldb->setAbstractParams(-1, prefs.syntAbsLen, prefs.syntAbsCtx);

View File

@ -345,25 +345,31 @@ void RclMain::initDbOpen()
bool needindexconfig = false; bool needindexconfig = false;
bool nodb = false; bool nodb = false;
string reason; string reason;
if (!maybeOpenDb(reason)) { bool maindberror;
if (!maybeOpenDb(reason, true, &maindberror)) {
nodb = true; nodb = true;
switch (QMessageBox:: if (maindberror) {
question switch (QMessageBox::
(this, "Recoll", question
qApp->translate("Main", "Could not open database in ") + (this, "Recoll",
QString::fromLocal8Bit(theconfig->getDbDir().c_str()) + qApp->translate("Main", "Could not open database in ") +
qApp->translate("Main", QString::fromLocal8Bit(theconfig->getDbDir().c_str()) +
".\n" qApp->translate("Main",
"Click Cancel if you want to edit the configuration file before indexing starts, or Ok to let it proceed."), ".\n"
"Ok", "Cancel", 0, 0)) { "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. case 0: // Ok: indexing is going to start.
start_indexing(true); start_indexing(true);
break; break;
case 1: // Cancel case 1: // Cancel
needindexconfig = true; needindexconfig = true;
break; break;
}
} else {
QMessageBox::warning(0, "Recoll",
tr("Could not open external index. Db not open. Check external indexes list."));
} }
} }

View File

@ -26,7 +26,8 @@
// Misc declarations in need of sharing between the UI files // Misc declarations in need of sharing between the UI files
// Open the database if needed. We now force a close/open by default // 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 */ /** Retrieve configured stemming languages */
bool getStemLangs(list<string>& langs); bool getStemLangs(list<string>& langs);

View File

@ -534,8 +534,11 @@ list<string> Db::getStemmerNames()
return res; 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) { if (m_ndb == 0 || m_config == 0) {
m_reason = "Null configuration or Xapian Db"; m_reason = "Null configuration or Xapian Db";
return false; return false;
@ -586,12 +589,17 @@ bool Db::open(OpenMode mode)
m_ndb->xrdb = Xapian::Database(dir); m_ndb->xrdb = Xapian::Database(dir);
for (list<string>::iterator it = m_extraDbs.begin(); for (list<string>::iterator it = m_extraDbs.begin();
it != m_extraDbs.end(); it++) { it != m_extraDbs.end(); it++) {
if (error)
*error = DbOpenExtraDb;
LOGDEB(("Db::Open: adding query db [%s]\n", it->c_str())); 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)); m_ndb->xrdb.add_database(Xapian::Database(*it));
} }
break; break;
} }
if (error)
*error = DbOpenMainDb;
// Check index format version. Must not try to check a just created or // Check index format version. Must not try to check a just created or
// truncated db // truncated db
@ -608,6 +616,8 @@ bool Db::open(OpenMode mode)
m_mode = mode; m_mode = mode;
m_ndb->m_isopen = true; m_ndb->m_isopen = true;
m_basedir = dir; m_basedir = dir;
if (error)
*error = DbOpenNoError;
return true; return true;
} XCATCHERROR(ermsg); } XCATCHERROR(ermsg);

View File

@ -95,7 +95,8 @@ class Db {
~Db(); ~Db();
enum OpenMode {DbRO, DbUpd, DbTrunc}; enum OpenMode {DbRO, DbUpd, DbTrunc};
bool open(OpenMode mode); enum OpenError {DbOpenNoError, DbOpenMainDb, DbOpenExtraDb};
bool open(OpenMode mode, OpenError *error = 0);
bool close(); bool close();
bool isopen(); bool isopen();

View File

@ -37,33 +37,35 @@
<h2><a name="b_latest">recoll 1.15</a></h2> <h2><a name="b_latest">recoll 1.15</a></h2>
<ul> <ul>
<li>Cancelling a preview in the GUI will also cancel the indexing
thread if it is running.</li>
<li>Using search preview while the indexing thread is running will <li>Using search preview while the indexing thread is running will
sometimes crash the GUI or provoke other strangeness. This sometimes crash the GUI or provoke other strangeness. This is
is due to insufficient protection of resources shared by apparently due to insufficient protection of resources shared by
several threads. The current and unsatisfying workaround, is several threads. After recent cleanup, the problem occurs quite
to avoid the situation, for example by using the standalone seldom but it is not completely gone. The current and
recollindex program instead of the GUI indexing thread. I unsatisfying workaround, is to avoid the situation, for example
will be working on a program-wide cleanup of multithreaded by using the standalone recollindex program instead of the GUI
operation for the next version.</li> indexing thread.</li>
<li>The operations on the parent document in the result list <li>The operations on the parent document in the result list
right click menu (Preview and Open), do not work, they right click menu (Preview and Open), do not work, they
access the file's parent directory instead.</li> access the file's parent directory instead.</li>
<li>The rclzip filter can't handle utf-8 in path names for archive <li>The rclzip filter can't handle utf-8 in path names for archive
members. An <a members. An <a href="http://www.recoll.org/filters/rclzip">
href="http://www.recoll.org/filters/rclzip">updated filter</a> is updated filter</a> is available. </li>
available. </li>
<li>The rclzip and rclchm filters can't handle archive members <li>The rclzip and rclchm filters can't handle archive members
with a colon (':') in the file name or path. The files are normally with a colon (':') in the file name or path. The files are normally
indexed and can be searched for, but they can't be displayed indexed and can be searched for, but they can't be displayed
(neither opened nor previewed). There is a <a (neither opened nor previewed). There is a
href="https://bitbucket.org/medoc/recoll/changeset/3751ea8ea179"> <a href="https://bitbucket.org/medoc/recoll/changeset/3751ea8ea179">
patch</a> which fixes the issue (then needs full reindex for these patch</a> which fixes the issue (then needs full reindex for these
files).</li> files).</li>
<li>After an upgrade, the recoll GUI sometimes crashes on <li>After an upgrade, the recoll GUI sometimes crashes on
startup. This is fixed by removing (back it up just in case) startup. This is fixed by removing (back it up just in case)