Add possibility to update the index for a list of files from the GUI and use it to allow updating the index before accessing a file using stale data
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
static int stopindexing;
|
||||
static int startindexing;
|
||||
static bool rezero;
|
||||
static vector<Rcl::Doc> idxdocs; // Docs to update. Update all if empty
|
||||
|
||||
static IdxThreadStatus indexingstatus = IDXTS_OK;
|
||||
static string indexingReason;
|
||||
static int stopidxthread;
|
||||
@@ -99,7 +101,11 @@ void IdxThread::run()
|
||||
} else {
|
||||
pidfile.write_pid();
|
||||
ConfIndexer *indexer = new ConfIndexer(myconf, this);
|
||||
if (indexer->index(rezero, ConfIndexer::IxTAll)) {
|
||||
bool status = idxdocs.empty() ?
|
||||
indexer->index(rezero, ConfIndexer::IxTAll) :
|
||||
indexer->updateDocs(idxdocs);
|
||||
|
||||
if (status) {
|
||||
indexingstatus = IDXTS_OK;
|
||||
indexingReason = "";
|
||||
} else {
|
||||
@@ -152,11 +158,12 @@ void stop_indexing()
|
||||
action_wait.wakeAll();
|
||||
}
|
||||
|
||||
void start_indexing(bool raz)
|
||||
void start_indexing(bool raz, vector<Rcl::Doc> docs)
|
||||
{
|
||||
action_mutex.lock();
|
||||
startindexing = 1;
|
||||
rezero = raz;
|
||||
idxdocs = docs;
|
||||
action_mutex.unlock();
|
||||
action_wait.wakeAll();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#define _IDXTHREAD_H_INCLUDED_
|
||||
#include <string>
|
||||
#include "indexer.h"
|
||||
#include "rcldoc.h"
|
||||
|
||||
// These two deal with starting / stopping the thread itself, not
|
||||
// indexing sessions.
|
||||
@@ -27,7 +28,8 @@ extern void start_idxthread();
|
||||
extern void stop_idxthread();
|
||||
|
||||
// Use these to to request action from thread
|
||||
extern void start_indexing(bool rezero = false);
|
||||
extern void start_indexing(bool rezero = false,
|
||||
const vector<Rcl::Doc> docs = vector<Rcl::Doc>());
|
||||
extern void stop_indexing();
|
||||
|
||||
// Final status of indexing. indexingstatus is NULL iff indexing is
|
||||
|
||||
+25
-6
@@ -950,19 +950,38 @@ void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
|
||||
// empty as this does not appear to be a serious issue for single
|
||||
// docs (the main actual problem is displaying the wrong message
|
||||
// from a compacted mail folder)
|
||||
//
|
||||
// !! NOTE: there is one case where doing a partial index update
|
||||
// will not worl: if the search result does not exist in the new
|
||||
// version of the file, it won't be purged from the index because
|
||||
// a partial index pass does no purge, so its ref date will stay
|
||||
// the same and you keep getting the message about the index being
|
||||
// out of date. The only way to fix this is to run a normal
|
||||
// indexing pass.
|
||||
// Also we should re-run the query after updating the index
|
||||
// because the ipaths may be wrong in the current result list
|
||||
if (!doc.ipath.empty()) {
|
||||
string udi, sig;
|
||||
doc.getmeta(Rcl::Doc::keyudi, &udi);
|
||||
FileInterner::makesig(doc, sig);
|
||||
if (rcldb && !udi.empty()) {
|
||||
if (rcldb->needUpdate(udi, sig)) {
|
||||
fprintf(stderr, "AFTER UPDATE CHECK-1\n");
|
||||
QMessageBox::warning(0, tr("Warning"),
|
||||
tr("Index not up to date for this file. "
|
||||
int rep =
|
||||
QMessageBox::warning(0, tr("Warning"),
|
||||
tr("Index not up to date for this file. "
|
||||
"Refusing to risk showing the wrong "
|
||||
"data. Please run indexing"),
|
||||
QMessageBox::Ok,
|
||||
QMessageBox::NoButton);
|
||||
"data. Click ok to update the "
|
||||
"index for this file, then re-run the "
|
||||
"query when indexing is done. "
|
||||
"Else, Cancel."),
|
||||
QMessageBox::Ok,
|
||||
QMessageBox::Cancel,
|
||||
QMessageBox::NoButton);
|
||||
if (rep == QMessageBox::Ok) {
|
||||
LOGDEB(("Requesting index update for %s\n",
|
||||
doc.url.c_str()));
|
||||
start_indexing(false, vector<Rcl::Doc>(1, doc));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user