catch xapian exceptions in 2 more places.
This commit is contained in:
parent
5d832cf458
commit
d776f85dc0
@ -1126,7 +1126,8 @@ bool Db::needUpdate(const string &udi, const string& sig)
|
||||
// the actual document file, or, for a multi-document file, the
|
||||
// pseudo-doc we create to stand for the file itself.
|
||||
|
||||
// We try twice in case database needs to be reopened.
|
||||
// We try twice in case database needs to be reopened. (Ulterior
|
||||
// note: this does not make sense as we are the sole writer!)
|
||||
for (int tries = 0; tries < 2; tries++) {
|
||||
try {
|
||||
// Get the doc or pseudo-doc
|
||||
@ -1579,8 +1580,24 @@ bool Db::makeDocAbstract(Doc &doc, Query *query, string& abstract)
|
||||
LOGERR(("Db::makeDocAbstract: no db\n"));
|
||||
return false;
|
||||
}
|
||||
abstract = m_ndb->makeAbstract(doc.xdocid, query);
|
||||
return true;
|
||||
m_reason.erase();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
try {
|
||||
abstract = m_ndb->makeAbstract(doc.xdocid, query);
|
||||
m_reason.erase();
|
||||
break;
|
||||
} catch (const Xapian::DatabaseModifiedError &error) {
|
||||
LOGDEB(("Db:makeDocAbstract: caught DatabaseModified\n"));
|
||||
m_reason = error.get_msg();
|
||||
reOpen();
|
||||
} catch (const Xapian::Error & error) {
|
||||
LOGERR(("Db::makeDocAbstract: exception: %s\n",
|
||||
error.get_msg().c_str()));
|
||||
m_reason = error.get_msg();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return m_reason.empty() ? true : false;
|
||||
}
|
||||
|
||||
// Retrieve document defined by file name and internal path.
|
||||
|
||||
@ -309,6 +309,7 @@ bool Query::getDoc(int exti, Doc &doc)
|
||||
} catch (const Xapian::Error & error) {
|
||||
LOGERR(("enquire->get_mset: exception: %s\n",
|
||||
error.get_msg().c_str()));
|
||||
m_reason = error.get_msg();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -349,6 +350,7 @@ bool Query::getDoc(int exti, Doc &doc)
|
||||
} catch (const Xapian::Error & error) {
|
||||
LOGERR(("enquire->get_mset: exception: %s\n",
|
||||
error.get_msg().c_str()));
|
||||
m_reason = error.get_msg();
|
||||
return false;
|
||||
}
|
||||
if (m_nq->mset.empty())
|
||||
@ -361,13 +363,32 @@ bool Query::getDoc(int exti, Doc &doc)
|
||||
m_nq->query.get_description().c_str(),
|
||||
first, last, m_nq->mset.get_matches_lower_bound()));
|
||||
|
||||
Xapian::Document xdoc = m_nq->mset[xapi-first].get_document();
|
||||
Xapian::docid docid = *(m_nq->mset[xapi-first]);
|
||||
int pc = m_nq->mset.convert_to_percent(m_nq->mset[xapi-first]);
|
||||
Xapian::Document xdoc;
|
||||
Xapian::docid docid = 0;
|
||||
int pc = 0;
|
||||
string data;
|
||||
m_reason.erase();
|
||||
for (int xaptries=0; xaptries < 2; xaptries++) {
|
||||
try {
|
||||
xdoc = m_nq->mset[xapi-first].get_document();
|
||||
docid = *(m_nq->mset[xapi-first]);
|
||||
pc = m_nq->mset.convert_to_percent(m_nq->mset[xapi-first]);
|
||||
data = xdoc.get_data();
|
||||
m_reason.erase();
|
||||
break;
|
||||
} catch (Xapian::DatabaseModifiedError &error) {
|
||||
// retry or end of loop
|
||||
LOGDEB(("getDoc: caught DatabaseModified\n"));
|
||||
m_reason = error.get_msg();
|
||||
continue;
|
||||
}
|
||||
XCATCHERROR(m_reason);
|
||||
break;
|
||||
}
|
||||
|
||||
// Parse xapian document's data and populate doc fields
|
||||
string data = xdoc.get_data();
|
||||
return m_db->m_ndb->dbDataToRclDoc(docid, data, doc, pc);
|
||||
return m_reason.empty() ?
|
||||
m_db->m_ndb->dbDataToRclDoc(docid, data, doc, pc) : false;
|
||||
}
|
||||
|
||||
list<string> Query::expand(const Doc &doc)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user