added index format version checking

This commit is contained in:
dockes
2008-09-30 12:38:29 +00:00
parent f0538b15f2
commit 722094e014
8 changed files with 82 additions and 40 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.12 2008-09-25 06:00:25 dockes Exp $ (C) 2007 J.F.Dockes";
static char rcsid[] = "@(#$Id: confguiindex.cpp,v 1.13 2008-09-30 12:38:29 dockes Exp $ (C) 2007 J.F.Dockes";
#endif
#include <qglobal.h>
@@ -98,7 +98,7 @@ void ConfIndexW::acceptChanges()
QTimer::singleShot(0, this, SLOT(reloadPanels()));
if (startIndexingAfterConfig) {
startIndexingAfterConfig = 0;
startindexing = 1;
start_indexing(true);
}
}
+24 -6
View File
@@ -27,10 +27,11 @@
#include "smallut.h"
#include "rclinit.h"
int stopindexing;
int startindexing;
IdxThreadStatus indexingstatus = IDXTS_OK;
string indexingReason;
static int stopindexing;
static int startindexing;
static bool rezero;
static IdxThreadStatus indexingstatus = IDXTS_OK;
static string indexingReason;
static int stopidxthread;
static QMutex curfile_mutex;
@@ -74,13 +75,14 @@ void IdxThread::run()
myconf->getConfParam("loglevel", &loglevel);
DebugLog::getdbl()->setloglevel(loglevel);
ConfIndexer *indexer = new ConfIndexer(myconf, this);
if (indexer->index()) {
if (indexer->index(rezero)) {
indexingstatus = IDXTS_OK;
indexingReason = "";
} else {
indexingstatus = IDXTS_ERROR;
indexingReason = "Indexing failed: " + indexer->getReason();
}
rezero = false;
delete indexer;
}
msleep(100);
@@ -101,7 +103,15 @@ void stop_idxthread()
stopidxthread = 1;
idxthread.wait();
}
void stop_indexing()
{
stopindexing = 1;
}
void start_indexing(bool raz)
{
startindexing = 1;
rezero = raz;
}
DbIxStatus idxthread_idxStatus()
{
QMutexLocker locker(&curfile_mutex);
@@ -111,3 +121,11 @@ bool idxthread_idxInterrupted()
{
return idxthread.m_interrupted;
}
string idxthread_getReason()
{
return indexingReason;
}
IdxThreadStatus idxthread_getStatus()
{
return indexingstatus;
}
+9 -8
View File
@@ -16,7 +16,7 @@
*/
#ifndef _IDXTHREAD_H_INCLUDED_
#define _IDXTHREAD_H_INCLUDED_
/* @(#$Id: idxthread.h,v 1.7 2008-01-17 11:15:43 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: idxthread.h,v 1.8 2008-09-30 12:38:29 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
#include "indexer.h"
@@ -27,15 +27,16 @@ class RclConfig;
extern void start_idxthread(const RclConfig& cnf);
extern void stop_idxthread();
// Set these to to request action
extern int stopindexing;
extern int startindexing;
// Use these to to request action from thread
extern void start_indexing(bool rezero = false);
extern void stop_indexing();
// indexingstatus is NULL iff indexing is currently in progress.
// Final status of indexing. indexingstatus is NULL iff indexing is
// currently in progress.
enum IdxThreadStatus {IDXTS_NULL = 0, IDXTS_OK = 1, IDXTS_ERROR = 2};
extern IdxThreadStatus indexingstatus;
// Final indexing status message
extern string indexingReason;
extern IdxThreadStatus idxthread_getStatus();
extern string idxthread_getReason();
// Current status of running indexing (phase, file name etc.)
extern DbIxStatus idxthread_idxStatus();
// Did last op fail because of stop request ?
+2 -3
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: main.cpp,v 1.69 2008-09-24 05:35:03 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: main.cpp,v 1.70 2008-09-30 12:38:29 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -338,12 +338,11 @@ int main(int argc, char **argv)
"Ok", "Cancel", 0, 0)) {
case 0: // Ok: indexing is going to start.
startindexing = 1;
start_indexing(true);
break;
case 1: // Cancel
needindexconfig = true;
startindexing = 0;
break;
}
}
+9 -9
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.54 2008-09-29 11:33:55 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.55 2008-09-30 12:38:29 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -358,20 +358,20 @@ void RclMain::periodic100()
{
static int toggle = 0;
// Check if indexing thread done
if (indexingstatus != IDXTS_NULL) {
if (idxthread_getStatus() != IDXTS_NULL) {
// Indexing is stopped
statusBar()->message("");
fileToggleIndexingAction->setText(tr("Update &Index"));
fileToggleIndexingAction->setEnabled(TRUE);
if (m_idxStatusAck == false) {
m_idxStatusAck = true;
if (indexingstatus != IDXTS_OK) {
if (idxthread_getStatus() != IDXTS_OK) {
if (idxthread_idxInterrupted()) {
QMessageBox::warning(0, "Recoll",
tr("Indexing interrupted"));
} else {
QMessageBox::warning(0, "Recoll",
QString::fromAscii(indexingReason.c_str()));
QString::fromAscii(idxthread_getReason().c_str()));
}
}
// Make sure we reopen the db to get the results. If there
@@ -427,12 +427,12 @@ void RclMain::periodic100()
void RclMain::toggleIndexing()
{
if (indexingstatus == IDXTS_NULL) {
if (idxthread_getStatus() == IDXTS_NULL) {
// Indexing in progress
stopindexing = 1;
stop_indexing();
fileToggleIndexingAction->setText(tr("Update &Index"));
} else {
startindexing = 1;
start_indexing(false);
fileToggleIndexingAction->setText(tr("Stop &Indexing"));
}
fileToggleIndexingAction->setEnabled(FALSE);
@@ -448,11 +448,11 @@ static string urltolocalpath(string url)
void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata)
{
LOGDEB(("RclMain::startSearch. Indexing %s\n",
indexingstatus == IDXTS_NULL?"on":"off"));
idxthread_getStatus() == IDXTS_NULL?"on":"off"));
// The db may have been closed at the end of indexing
string reason;
// If indexing is being performed, we reopen the db at each query.
if (!maybeOpenDb(reason, indexingstatus == IDXTS_NULL)) {
if (!maybeOpenDb(reason, idxthread_getStatus() == IDXTS_NULL)) {
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
return;
}