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

3
.gitignore vendored
View File

@ -20,9 +20,9 @@
\#* \#*
libtool libtool
ptrans ptrans
src/python/pychm/setup.py
src/Makefile src/Makefile
src/Makefile.in src/Makefile.in
src/TAGS
src/aclocal.m4 src/aclocal.m4
src/autom4te.cache src/autom4te.cache
src/common/autoconfig.h src/common/autoconfig.h
@ -50,6 +50,7 @@ src/m4/ltsugar.m4
src/m4/ltversion.m4 src/m4/ltversion.m4
src/m4/lt~obsolete.m4 src/m4/lt~obsolete.m4
src/missing src/missing
src/python/pychm/setup.py
src/python/recoll/Makefile src/python/recoll/Makefile
src/python/recoll/build src/python/recoll/build
src/python/recoll/recoll/__init__.pyc src/python/recoll/recoll/__init__.pyc

View File

@ -87,6 +87,13 @@ void RclMain::updateIdxStatus()
void RclMain::periodic100() void RclMain::periodic100()
{ {
LOGDEB2("Periodic100\n" ); LOGDEB2("Periodic100\n" );
if (!m_idxreasontmp || !m_idxreasontmp->ok()) {
// We just store the pointer and let the tempfile cleaner deal
// with delete on exiting
TempFile temp(".txt");
m_idxreasontmp = rememberTempFile(temp);
}
if (m_idxproc) { if (m_idxproc) {
// An indexing process was launched. If its' done, see status. // An indexing process was launched. If its' done, see status.
int status; int status;
@ -237,13 +244,6 @@ bool RclMain::checkIdxPaths()
// re-enabled by the indexing status check // re-enabled by the indexing status check
void RclMain::toggleIndexing() void RclMain::toggleIndexing()
{ {
if (!m_idxreasontmp || !m_idxreasontmp->ok()) {
// We just store the pointer and let the tempfile cleaner deal
// with delete on exiting
TempFile temp(".txt");
m_idxreasontmp = rememberTempFile(temp);
}
switch (m_indexerState) { switch (m_indexerState) {
case IXST_RUNNINGMINE: case IXST_RUNNINGMINE:
if (m_idxproc) { if (m_idxproc) {
@ -537,7 +537,7 @@ void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
vector<string> paths; vector<string> paths;
if (Rcl::docsToPaths(docs, paths)) { if (Rcl::docsToPaths(docs, paths)) {
vector<string> args{"-c", theconfig->getConfDir(), "-e", "-i"}; vector<string> args{"-c", theconfig->getConfDir(), "-i",};
if (m_idxreasontmp && m_idxreasontmp->ok()) { if (m_idxreasontmp && m_idxreasontmp->ok()) {
args.push_back("-R"); args.push_back("-R");
args.push_back(m_idxreasontmp->filename()); args.push_back(m_idxreasontmp->filename());
@ -545,8 +545,12 @@ void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
args.insert(args.end(), paths.begin(), paths.end()); args.insert(args.end(), paths.begin(), paths.end());
m_idxproc = new ExecCmd; m_idxproc = new ExecCmd;
m_idxproc->startExec("recollindex", args, false, false); m_idxproc->startExec("recollindex", args, false, false);
fileToggleIndexingAction->setText(tr("Stop &Indexing")); // Call periodic100 to update the menu entries states
periodic100();
} else {
QMessageBox::warning(0, tr("Warning"),
tr("Can't update index: internal error"),
QMessageBox::Ok, QMessageBox::NoButton);
return;
} }
fileToggleIndexingAction->setEnabled(false);
actionSpecial_Indexing->setEnabled(false);
} }

View File

@ -79,17 +79,27 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc)
return true; return true;
} }
// Top level (container) document, for checking for indexing error
string ctsig = "+";
Rcl::Doc ctdoc;
if (rcldb->getContainerDoc(doc, ctdoc)) {
ctdoc.getmeta(Rcl::Doc::keysig, &ctsig);
}
// We can only run indexing on the main index (dbidx 0) // We can only run indexing on the main index (dbidx 0)
bool ismainidx = rcldb->fromMainIndex(doc); bool ismainidx = rcldb->fromMainIndex(doc);
// Indexer already running? // Indexer already running?
bool ixnotact = (m_indexerState == IXST_NOTRUNNING); bool ixnotact = (m_indexerState == IXST_NOTRUNNING);
QString msg = tr("Index not up to date for this file. " QString msg = tr("Index not up to date for this file.<br>");
"Refusing to risk showing the wrong entry. "); if (ctsig.back() == '+') {
msg += tr("<em>Also, it seems that the last index update for the file "
"failed.</em><br/>");
}
if (ixnotact && ismainidx) { if (ixnotact && ismainidx) {
msg += tr("Click Ok to update the " msg += tr("Click Ok to try to update the "
"index for this file, then you will need to " "index for this file. You will need to "
"re-run the query when indexing is done. "); "run the query again when indexing is done.<br>");
} else if (ismainidx) { } else if (ismainidx) {
msg += tr("The indexer is running so things should " msg += tr("The indexer is running so things should "
"improve when it's done. "); "improve when it's done. ");
@ -98,9 +108,9 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc)
msg += tr("The document belongs to an external index " msg += tr("The document belongs to an external index "
"which I can't update. "); "which I can't update. ");
} }
msg += tr("Click Cancel to return to the list. <br>" msg += tr("Click Cancel to return to the list.<br>"
"Click Ignore to show the preview anyway (and remember for " "Click Ignore to show the preview anyway (and remember for "
"this session)."); "this session). There is a risk of showing the wrong entry.<br/>");
QMessageBox::StandardButtons bts = QMessageBox::StandardButtons bts =
QMessageBox::Ignore | QMessageBox::Cancel; QMessageBox::Ignore | QMessageBox::Cancel;

View File

@ -2584,6 +2584,53 @@ bool Db::getSubDocs(const Doc &idoc, vector<Doc>& subdocs)
return false; 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 // Walk an UDI section (all UDIs beginning with input prefix), and
// mark all docs and subdocs as existing. Caller beware: Makes sense // mark all docs and subdocs as existing. Caller beware: Makes sense
// or not depending on the UDI structure for the data store. In practise, // 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; return false;
} }
i_setExistingFlags(udi, *docid); i_setExistingFlags(udi, *docid);
LOGDEB("Db::udiTreeWalk: uniterm: " << term << endl); LOGDEB0("Db::udiTreeWalk: uniterm: " << term << endl);
return true; return true;
}, wrapd); }, wrapd);
return ret; return ret;

View File

@ -455,6 +455,12 @@ public:
*/ */
bool getSubDocs(const Doc& idoc, vector<Doc>& subdocs); 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 */ /** Get duplicates (md5) of document */
bool docDups(const Doc& idoc, std::vector<Doc>& odocs); bool docDups(const Doc& idoc, std::vector<Doc>& odocs);