diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index a99f953a..9ca258dc 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -1232,7 +1232,12 @@ void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod) doc.getmeta(Rcl::Doc::keyudi, &udi); if (!udi.empty()) { string sig; - FileInterner::makesig(theconfig, doc, sig); + if (!FileInterner::makesig(theconfig, doc, sig)) { + QMessageBox::warning(0, "Recoll", + tr("Can't access file: ") + + QString::fromLocal8Bit(doc.url.c_str())); + return; + } if (rcldb->needUpdate(udi, sig)) { QString msg = tr("Index not up to date for this file. " diff --git a/src/rcldb/rcldb.cpp b/src/rcldb/rcldb.cpp index e333161c..a18eb409 100644 --- a/src/rcldb/rcldb.cpp +++ b/src/rcldb/rcldb.cpp @@ -314,13 +314,15 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data, if (!parms.ok()) return false; + // Set xdocid at once so that we can call whatDbIdx() + doc.xdocid = docid; // Compute what index this comes from, and check for path translations string dbdir = m_rcldb->m_basedir; if (!m_rcldb->m_extraDbs.empty()) { - // As per trac.xapian.org/wiki/FAQ/MultiDatabaseDocumentID - unsigned int idxi = (docid-1) % (m_rcldb->m_extraDbs.size()+1); - // idxi is in [0, extraDbs.size()]. 0 is the base index, 1-n index - // into the additional dbs array + unsigned int idxi = m_rcldb->whatDbIdx(doc); + + // idxi is in [0, extraDbs.size()]. 0 is for the main index, + // idxi-1 indexes into the additional dbs array. if (idxi) { dbdir = m_rcldb->m_extraDbs[idxi - 1]; } @@ -349,7 +351,6 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data, parms.get(Doc::keyfs, doc.fbytes); parms.get(Doc::keyds, doc.dbytes); parms.get(Doc::keysig, doc.sig); - doc.xdocid = docid; // Normal key/value pairs: vector keys = parms.getNames(string()); @@ -847,13 +848,13 @@ bool Db::rmQueryDb(const string &dir) // http://trac.xapian.org/wiki/FAQ/MultiDatabaseDocumentID size_t Db::whatDbIdx(const Doc& doc) { - LOGDEB(("Db::whatDbIdx: xdocid %lu, %u extraDbs\n", - (unsigned long)doc.xdocid, m_extraDbs.size())); + LOGDEB1(("Db::whatDbIdx: xdocid %lu, %u extraDbs\n", + (unsigned long)doc.xdocid, m_extraDbs.size())); if (doc.xdocid == 0) return (size_t)-1; if (m_extraDbs.size() == 0) return 0; - return doc.xdocid % (m_extraDbs.size()+1); + return (doc.xdocid - 1) % (m_extraDbs.size() + 1); } bool Db::testDbDir(const string &dir, bool *stripped_p)