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:
+15
-11
@@ -87,6 +87,13 @@ void RclMain::updateIdxStatus()
|
||||
void RclMain::periodic100()
|
||||
{
|
||||
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) {
|
||||
// An indexing process was launched. If its' done, see status.
|
||||
int status;
|
||||
@@ -237,13 +244,6 @@ bool RclMain::checkIdxPaths()
|
||||
// re-enabled by the indexing status check
|
||||
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) {
|
||||
case IXST_RUNNINGMINE:
|
||||
if (m_idxproc) {
|
||||
@@ -537,7 +537,7 @@ void RclMain::updateIdxForDocs(vector<Rcl::Doc>& docs)
|
||||
|
||||
vector<string> 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()) {
|
||||
args.push_back("-R");
|
||||
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());
|
||||
m_idxproc = new ExecCmd;
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -79,17 +79,27 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc)
|
||||
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)
|
||||
bool ismainidx = rcldb->fromMainIndex(doc);
|
||||
// Indexer already running?
|
||||
bool ixnotact = (m_indexerState == IXST_NOTRUNNING);
|
||||
|
||||
QString msg = tr("Index not up to date for this file. "
|
||||
"Refusing to risk showing the wrong entry. ");
|
||||
QString msg = tr("Index not up to date for this file.<br>");
|
||||
if (ctsig.back() == '+') {
|
||||
msg += tr("<em>Also, it seems that the last index update for the file "
|
||||
"failed.</em><br/>");
|
||||
}
|
||||
if (ixnotact && ismainidx) {
|
||||
msg += tr("Click Ok to update the "
|
||||
"index for this file, then you will need to "
|
||||
"re-run the query when indexing is done. ");
|
||||
msg += tr("Click Ok to try to update the "
|
||||
"index for this file. You will need to "
|
||||
"run the query again when indexing is done.<br>");
|
||||
} else if (ismainidx) {
|
||||
msg += tr("The indexer is running so things should "
|
||||
"improve when it's done. ");
|
||||
@@ -98,9 +108,9 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc)
|
||||
msg += tr("The document belongs to an external index "
|
||||
"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 "
|
||||
"this session).");
|
||||
"this session). There is a risk of showing the wrong entry.<br/>");
|
||||
|
||||
QMessageBox::StandardButtons bts =
|
||||
QMessageBox::Ignore | QMessageBox::Cancel;
|
||||
|
||||
Reference in New Issue
Block a user