GUI preview: improve operation when the index data is not up to date.

Avoid erasing all the file index data in case the subsequent update fails
(e.g. the file is locked). Improve the messages. Check for previous
indexing error, and modify the message.
This commit is contained in:
Jean-Francois Dockes
2019-06-24 17:37:37 +02:00
parent 4c2fd82d4e
commit 3f7d270691
5 changed files with 88 additions and 20 deletions
+48 -1
View File
@@ -2584,6 +2584,53 @@ bool Db::getSubDocs(const Doc &idoc, vector<Doc>& subdocs)
return false;
}
bool Db::getContainerDoc(const Doc &idoc, Doc& ctdoc)
{
if (m_ndb == 0)
return false;
string inudi;
if (!idoc.getmeta(Doc::keyudi, &inudi) || inudi.empty()) {
LOGERR("Db::getContainerDoc: no input udi or empty\n");
return false;
}
string rootudi;
string ipath = idoc.ipath;
LOGDEB0("Db::getContainerDoc: idxi " << idoc.idxi << " inudi [" << inudi <<
"] ipath [" << ipath << "]\n");
if (ipath.empty()) {
// File-level doc ??
ctdoc = idoc;
return true;
}
// See if we have a parent term
Xapian::Document xdoc;
if (!m_ndb->getDoc(inudi, idoc.idxi, xdoc)) {
LOGERR("Db::getContainerDoc: can't get Xapian document\n");
return false;
}
Xapian::TermIterator xit;
XAPTRY(xit = xdoc.termlist_begin();
xit.skip_to(wrap_prefix(parent_prefix)),
m_ndb->xrdb, m_reason);
if (!m_reason.empty()) {
LOGERR("Db::getContainerDoc: xapian error: " << m_reason << "\n");
return false;
}
if (xit == xdoc.termlist_end()) {
LOGERR("Db::getContainerDoc: parent term not found\n");
return false;
}
rootudi = strip_prefix(*xit);
if (!getDoc(rootudi, idoc.idxi, ctdoc)) {
LOGERR("Db::getContainerDoc: can't get container document\n");
return false;
}
return true;
}
// Walk an UDI section (all UDIs beginning with input prefix), and
// mark all docs and subdocs as existing. Caller beware: Makes sense
// or not depending on the UDI structure for the data store. In practise,
@@ -2614,7 +2661,7 @@ bool Db::udiTreeMarkExisting(const string& udi)
return false;
}
i_setExistingFlags(udi, *docid);
LOGDEB("Db::udiTreeWalk: uniterm: " << term << endl);
LOGDEB0("Db::udiTreeWalk: uniterm: " << term << endl);
return true;
}, wrapd);
return ret;
+6
View File
@@ -455,6 +455,12 @@ public:
*/
bool getSubDocs(const Doc& idoc, vector<Doc>& subdocs);
/** Get container (top level file) document.
*
* If the input is not a subdocument, this returns a copy of the input.
*/
bool getContainerDoc(const Doc &idoc, Doc& ctdoc);
/** Get duplicates (md5) of document */
bool docDups(const Doc& idoc, std::vector<Doc>& odocs);