*** empty log message ***

This commit is contained in:
dockes 2005-02-01 08:42:56 +00:00
parent a93e619960
commit cc512e2ec0
11 changed files with 246 additions and 186 deletions

View File

@ -1,5 +1,5 @@
include ../mk/FreeBSD
BIGLIB = ../lib/librcl.a BIGLIB = ../lib/librcl.a
CXXFLAGS = -Wall -g -I. -I../unac -I../utils -I/usr/local/include
PROGS = unacpp textsplit PROGS = unacpp textsplit

View File

@ -1,5 +1,5 @@
CXXFLAGS = -Wall -g -I. -I../utils -I../common -I/usr/local/include include ../mk/FreeBSD
BIGLIB = ../lib/librcl.a BIGLIB = ../lib/librcl.a

View File

@ -1,10 +1,11 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.8 2005-01-31 14:31:09 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.9 2005-02-01 08:42:56 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include "debuglog.h"
#include "indexer.h" #include "indexer.h"
ConfIndexer *indexer; ConfIndexer *indexer;
@ -34,6 +35,8 @@ int main(int argc, const char **argv)
if (signal(SIGTERM, SIG_IGN) != SIG_IGN) if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
signal(SIGTERM, sigcleanup); signal(SIGTERM, sigcleanup);
DebugLog::getdbl()->setloglevel(DEBDEB1);
DebugLog::setfilename("stderr");
RclConfig config; RclConfig config;
if (!config.ok()) { if (!config.ok()) {
fprintf(stderr, "Config could not be built\n"); fprintf(stderr, "Config could not be built\n");

View File

@ -1,5 +1,4 @@
CXXFLAGS = -Wall -g -I. -I../index -I../utils -I../common \ include ../mk/FreeBSD
-I../unac -I/usr/local/include
UNACCFLAGS = -g -I. -I../unac -I/usr/local/include -DUNAC_VERSION=\"1.0.7\" UNACCFLAGS = -g -I. -I../unac -I/usr/local/include -DUNAC_VERSION=\"1.0.7\"

View File

@ -3,6 +3,7 @@
#include "indexer.h" #include "indexer.h"
#include "debuglog.h" #include "debuglog.h"
#include "idxthread.h"
class IdxThread : public QThread { class IdxThread : public QThread {
virtual void run(); virtual void run();
@ -11,9 +12,10 @@ class IdxThread : public QThread {
}; };
int startindexing; int startindexing;
int indexingdone; int indexingdone = 1;
bool indexingstatus; bool indexingstatus = false;
int stopidxthread;
static int stopidxthread;
void IdxThread::run() void IdxThread::run()
{ {
@ -24,9 +26,10 @@ void IdxThread::run()
return; return;
} }
if (startindexing) { if (startindexing) {
indexingdone = indexingstatus = startindexing = 0; indexingdone = indexingstatus = 0;
fprintf(stderr, "Index thread :start index\n"); fprintf(stderr, "Index thread :start index\n");
indexingstatus = indexer->index(); indexingstatus = indexer->index();
startindexing = 0;
indexingdone = 1; indexingdone = 1;
} }
msleep(100); msleep(100);

View File

@ -9,13 +9,12 @@
#include "rcldb.h" #include "rcldb.h"
#include "rclconfig.h" #include "rclconfig.h"
#include "pathut.h" #include "pathut.h"
#include "recoll.h"
RclConfig *rclconfig; RclConfig *rclconfig;
Rcl::Db *rcldb; Rcl::Db *rcldb;
int recollNeedsExit;
extern void start_idxthread(RclConfig *cnf);
extern void stop_idxthread();
extern int startindexing;
void recollCleanup() void recollCleanup()
{ {
@ -26,7 +25,6 @@ void recollCleanup()
rclconfig = 0; rclconfig = 0;
} }
int recollNeedsExit;
static void sigcleanup(int sig) static void sigcleanup(int sig)
{ {

View File

@ -29,156 +29,157 @@
</property> </property>
<widget class="QLayoutWidget"> <widget class="QLayoutWidget">
<property name="name"> <property name="name">
<cstring>layout10</cstring> <cstring>layout3</cstring>
</property> </property>
<vbox> <hbox>
<property name="name"> <property name="name">
<cstring>unnamed</cstring> <cstring>unnamed</cstring>
</property> </property>
<widget class="QLayoutWidget"> <widget class="QLineEdit">
<property name="name"> <property name="name">
<cstring>layout8</cstring> <cstring>queryText</cstring>
</property>
<property name="frameShape">
<enum>LineEditPanel</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property> </property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLineEdit">
<property name="name">
<cstring>queryText</cstring>
</property>
<property name="frameShape">
<enum>LineEditPanel</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>Search</cstring>
</property>
<property name="text">
<string>Search</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>listPrevPb</cstring>
</property>
<property name="text">
<string>Previous page</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>listNextPB</cstring>
</property>
<property name="text">
<string>Next page</string>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>346</width>
<height>20</height>
</size>
</property>
</spacer>
</hbox>
</widget> </widget>
<widget class="QSplitter"> <widget class="QPushButton">
<property name="name"> <property name="name">
<cstring>splitter6</cstring> <cstring>Search</cstring>
</property>
<property name="text">
<string>Search</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>clearqPB</cstring>
</property>
<property name="text">
<string>Clear</string>
</property>
<property name="accel">
<string>Ctrl+S</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>listPrevPb</cstring>
</property>
<property name="text">
<string>Previous page</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>listNextPB</cstring>
</property>
<property name="text">
<string>Next page</string>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer1</cstring>
</property> </property>
<property name="orientation"> <property name="orientation">
<enum>Horizontal</enum> <enum>Horizontal</enum>
</property> </property>
<widget class="QTextEdit"> <property name="sizeType">
<property name="name"> <enum>Expanding</enum>
<cstring>reslistTE</cstring> </property>
</property> <property name="sizeHint">
<property name="sizePolicy"> <size>
<sizepolicy> <width>346</width>
<hsizetype>5</hsizetype> <height>20</height>
<vsizetype>5</vsizetype> </size>
<horstretch>2</horstretch> </property>
<verstretch>0</verstretch> </spacer>
</sizepolicy> </hbox>
</property> </widget>
<property name="textFormat"> <widget class="QSplitter">
<enum>RichText</enum> <property name="name">
</property> <cstring>splitter6</cstring>
<property name="readOnly"> </property>
<bool>true</bool> <property name="orientation">
</property> <enum>Horizontal</enum>
</widget> </property>
<widget class="QSplitter"> <widget class="QTextEdit">
<property name="name"> <property name="name">
<cstring>splitter5</cstring> <cstring>reslistTE</cstring>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy> <sizepolicy>
<hsizetype>5</hsizetype> <hsizetype>5</hsizetype>
<vsizetype>5</vsizetype> <vsizetype>5</vsizetype>
<horstretch>5</horstretch> <horstretch>2</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="orientation"> <property name="textFormat">
<enum>Vertical</enum> <enum>RichText</enum>
</property> </property>
<widget class="QTextEdit"> <property name="readOnly">
<property name="name"> <bool>true</bool>
<cstring>previewTextEdit</cstring> </property>
</property> </widget>
<property name="sizePolicy"> <widget class="QSplitter">
<sizepolicy> <property name="name">
<hsizetype>7</hsizetype> <cstring>splitter5</cstring>
<vsizetype>7</vsizetype> </property>
<horstretch>0</horstretch> <property name="sizePolicy">
<verstretch>4</verstretch> <sizepolicy>
</sizepolicy> <hsizetype>5</hsizetype>
</property> <vsizetype>5</vsizetype>
<property name="textFormat"> <horstretch>5</horstretch>
<enum>RichText</enum> <verstretch>0</verstretch>
</property> </sizepolicy>
<property name="readOnly"> </property>
<bool>true</bool> <property name="orientation">
</property> <enum>Vertical</enum>
</widget> </property>
<widget class="QTextEdit"> <widget class="QTextEdit">
<property name="name"> <property name="name">
<cstring>metaTextEdit</cstring> <cstring>previewTextEdit</cstring>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy> <sizepolicy>
<hsizetype>7</hsizetype> <hsizetype>7</hsizetype>
<vsizetype>7</vsizetype> <vsizetype>7</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>1</verstretch> <verstretch>4</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>RichText</enum> <enum>RichText</enum>
</property> </property>
<property name="readOnly"> <property name="readOnly">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget>
</widget>
</widget> </widget>
</vbox> <widget class="QTextEdit">
<property name="name">
<cstring>metaTextEdit</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="textFormat">
<enum>RichText</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</widget>
</widget> </widget>
</vbox> </vbox>
</widget> </widget>
@ -189,6 +190,8 @@
<item text="&amp;File" name="fileMenu"> <item text="&amp;File" name="fileMenu">
<separator/> <separator/>
<separator/> <separator/>
<action name="fileStart_IndexingAction"/>
<separator/>
<action name="fileExitAction"/> <action name="fileExitAction"/>
</item> </item>
<item text="&amp;Help" name="helpMenu"> <item text="&amp;Help" name="helpMenu">
@ -212,6 +215,17 @@
<string></string> <string></string>
</property> </property>
</action> </action>
<action>
<property name="name">
<cstring>fileStart_IndexingAction</cstring>
</property>
<property name="text">
<string>Start Indexing</string>
</property>
<property name="menuText">
<string>Start Indexing</string>
</property>
</action>
</actions> </actions>
<connections> <connections>
<connection> <connection>
@ -256,6 +270,18 @@
<receiver>RecollMain</receiver> <receiver>RecollMain</receiver>
<slot>reslistTE_clicked(int,int)</slot> <slot>reslistTE_clicked(int,int)</slot>
</connection> </connection>
<connection>
<sender>fileStart_IndexingAction</sender>
<signal>activated()</signal>
<receiver>RecollMain</receiver>
<slot>fileStart_IndexingAction_activated()</slot>
</connection>
<connection>
<sender>clearqPB</sender>
<signal>clicked()</signal>
<receiver>RecollMain</receiver>
<slot>clearqPB_clicked()</slot>
</connection>
</connections> </connections>
<includes> <includes>
<include location="local" impldecl="in implementation">recollmain.ui.h</include> <include location="local" impldecl="in implementation">recollmain.ui.h</include>
@ -267,10 +293,12 @@
<slots> <slots>
<slot>fileExit()</slot> <slot>fileExit()</slot>
<slot>checkExit()</slot> <slot>checkExit()</slot>
<slot>reslistTE_doubleClicked( int par, int car )</slot> <slot>fileStart_IndexingAction_activated()</slot>
<slot>reslistTE_doubleClicked( int par, int )</slot>
<slot>reslistTE_clicked( int par, int car )</slot> <slot>reslistTE_clicked( int par, int car )</slot>
<slot>queryText_returnPressed()</slot> <slot>queryText_returnPressed()</slot>
<slot>Search_clicked()</slot> <slot>Search_clicked()</slot>
<slot>clearqPB_clicked()</slot>
<slot>listPrevPB_clicked()</slot> <slot>listPrevPB_clicked()</slot>
<slot>listNextPB_clicked()</slot> <slot>listNextPB_clicked()</slot>
</slots> </slots>

View File

@ -23,24 +23,34 @@
#include "debuglog.h" #include "debuglog.h"
#include "mimehandler.h" #include "mimehandler.h"
#include "pathut.h" #include "pathut.h"
#include "recoll.h"
extern RclConfig *rclconfig;
extern Rcl::Db *rcldb;
extern void recollCleanup();
void RecollMain::fileExit() void RecollMain::fileExit()
{ {
LOGDEB(("RecollMain: fileExit\n")); LOGDEB(("RecollMain: fileExit\n"));
exit(0); exit(0);
} }
extern int recollNeedsExit; // Misnomer. This is called on a 100ms timer and actually checks for different
// things apart from a need to exit
void RecollMain::checkExit() void RecollMain::checkExit()
{ {
if (indexingstatus) {
indexingstatus = false;
// Make sure we reopen the db to get the results.
fprintf(stderr, "Indexing done: closing query database\n");
rcldb->close();
}
if (recollNeedsExit) if (recollNeedsExit)
fileExit(); fileExit();
} }
void RecollMain::fileStart_IndexingAction_activated()
{
if (indexingdone == 1)
startindexing = 1;
}
static string plaintorich(const string &in) static string plaintorich(const string &in)
{ {
string out = "<qt><head><title></title></head><body><p>"; string out = "<qt><head><title></title></head><body><p>";
@ -60,7 +70,7 @@ static string urltolocalpath(string url)
} }
// Use external viewer to display file // Use external viewer to display file
void RecollMain::reslistTE_doubleClicked(int par, int car) void RecollMain::reslistTE_doubleClicked(int par, int)
{ {
// restlistTE_clicked(par, car); // restlistTE_clicked(par, car);
Rcl::Doc doc; Rcl::Doc doc;
@ -215,6 +225,10 @@ void RecollMain::Search_clicked()
queryText_returnPressed(); queryText_returnPressed();
} }
void RecollMain::clearqPB_clicked()
{
queryText->clear();
}
static const int respagesize = 10; static const int respagesize = 10;
void RecollMain::listPrevPB_clicked() void RecollMain::listPrevPB_clicked()
@ -307,3 +321,4 @@ void RecollMain::listNextPB_clicked()
} }
} }

View File

@ -1,5 +1,4 @@
include ../mk/FreeBSD
CXXFLAGS = -Wall -g -I. -I../index -I../utils -I../common -I/usr/local/include
BIGLIB=../lib/librcl.a BIGLIB=../lib/librcl.a

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.14 2005-01-31 14:31:09 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.15 2005-02-01 08:42:55 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
@ -57,6 +57,7 @@ Rcl::Db::~Db()
ndb->iswritable)); ndb->iswritable));
if (ndb->isopen == false) if (ndb->isopen == false)
return; return;
string ermsg;
try { try {
LOGDEB(("Rcl::Db::~Db: deleting native database\n")); LOGDEB(("Rcl::Db::~Db: deleting native database\n"));
if (ndb->iswritable == true) if (ndb->iswritable == true)
@ -64,15 +65,15 @@ Rcl::Db::~Db()
delete ndb; delete ndb;
return; return;
} catch (const Xapian::Error &e) { } catch (const Xapian::Error &e) {
cerr << "Exception: " << e.get_msg() << endl; ermsg = e.get_msg();
} catch (const string &s) { } catch (const string &s) {
cerr << "Exception: " << s << endl; ermsg = s;
} catch (const char *s) { } catch (const char *s) {
cerr << "Exception: " << s << endl; ermsg = s;
} catch (...) { } catch (...) {
cerr << "Caught unknown exception" << endl; ermsg = "Caught unknown exception";
} }
LOGERR(("Rcl::Db::~Db: got exception\n")); LOGERR(("Rcl::Db::~Db: got exception: %s\n", ermsg.c_str()));
} }
bool Rcl::Db::open(const string& dir, OpenMode mode) bool Rcl::Db::open(const string& dir, OpenMode mode)
@ -93,7 +94,11 @@ bool Rcl::Db::open(const string& dir, OpenMode mode)
case DbUpd: case DbUpd:
ndb->wdb = ndb->wdb =
Xapian::WritableDatabase(dir, Xapian::DB_CREATE_OR_OPEN); Xapian::WritableDatabase(dir, Xapian::DB_CREATE_OR_OPEN);
LOGDEB(("Rcl::Db::open: lastdocid: %d\n",
ndb->wdb.get_lastdocid()));
ndb->updated.resize(ndb->wdb.get_lastdocid() + 1); ndb->updated.resize(ndb->wdb.get_lastdocid() + 1);
for (unsigned int i = 0; i < ndb->updated.size(); i++)
ndb->updated[i] = false;
ndb->iswritable = true; ndb->iswritable = true;
break; break;
case DbTrunc: case DbTrunc:
@ -133,27 +138,27 @@ bool Rcl::Db::close()
ndb->iswritable)); ndb->iswritable));
if (ndb->isopen == false) if (ndb->isopen == false)
return true; return true;
string ermsg;
try { try {
if (ndb->iswritable == true) if (ndb->iswritable == true) {
ndb->wdb.flush(); ndb->wdb.flush();
LOGDEB(("Called xapian flush\n"));
}
delete ndb; delete ndb;
pdata = new Native;
if (pdata)
return true;
} catch (const Xapian::Error &e) { } catch (const Xapian::Error &e) {
cerr << "Exception: " << e.get_msg() << endl; ermsg = e.get_msg();
return false;
} catch (const string &s) { } catch (const string &s) {
cerr << "Exception: " << s << endl; ermsg = s;
return false;
} catch (const char *s) { } catch (const char *s) {
cerr << "Exception: " << s << endl; ermsg = s;
return false;
} catch (...) { } catch (...) {
cerr << "Caught unknown exception" << endl; ermsg = "Caught unknown exception";
return false;
} }
LOGERR(("Rcl::Db:close: exception while deleting db: %s\n",
pdata = new Native; ermsg.c_str()));
if (pdata)
return true;
return false; return false;
} }
@ -290,9 +295,9 @@ bool Rcl::Db::add(const string &fn, const Rcl::Doc &doc)
ndb->wdb.replace_document(pathterm, newdocument); ndb->wdb.replace_document(pathterm, newdocument);
if (did < ndb->updated.size()) { if (did < ndb->updated.size()) {
ndb->updated[did] = true; ndb->updated[did] = true;
LOGDEB(("%s updated\n", fnc)); LOGDEB(("docid %d updated [%s]\n", did, fnc));
} else { } else {
LOGDEB(("%s added\n", fnc)); LOGDEB(("docid %d added [%s]\n", did, fnc));
} }
} catch (...) { } catch (...) {
// FIXME: is this ever actually needed? // FIXME: is this ever actually needed?
@ -318,15 +323,13 @@ bool Rcl::Db::needUpdate(const string &filename, const struct stat *stp)
if (did == ndb->wdb.postlist_end(pathterm)) if (did == ndb->wdb.postlist_end(pathterm))
return true; return true;
Xapian::Document doc = ndb->wdb.get_document(*did); Xapian::Document doc = ndb->wdb.get_document(*did);
if (*did < ndb->updated.size())
ndb->updated[*did] = true;
string data = doc.get_data(); string data = doc.get_data();
//cerr << "DOCUMENT EXISTS " << data << endl;
const char *cp = strstr(data.c_str(), "mtime="); const char *cp = strstr(data.c_str(), "mtime=");
cp += 6; cp += 6;
long mtime = atol(cp); long mtime = atol(cp);
if (mtime >= stp->st_mtime) { if (mtime >= stp->st_mtime) {
// cerr << "DOCUMENT UP TO DATE" << endl; if (*did < ndb->updated.size())
ndb->updated[*did] = true;
return false; return false;
} }
} catch (...) { } catch (...) {
@ -338,18 +341,31 @@ bool Rcl::Db::needUpdate(const string &filename, const struct stat *stp)
bool Rcl::Db::purge() bool Rcl::Db::purge()
{ {
LOGDEB(("Rcl::Db::purge\n"));
// There seems to be problems with the document delete code, when
// we do this, the database is not actually updated. Especially,
// if we delete a bunch of docs, so that there is a hole in the
// docids at the beginning, we can't add anything (appears to work
// and does nothing). Maybe related to the exceptions below when
// trying to delete an unexistant document ?
// Flushing before trying the deletes seeems to work around the problem
if (pdata == 0) if (pdata == 0)
return false; return false;
Native *ndb = (Native *)pdata; Native *ndb = (Native *)pdata;
LOGDEB(("Rcl::Db::purge: isopen %d iswritable %d\n", ndb->isopen,
ndb->iswritable));
if (ndb->isopen == false || ndb->iswritable == false) if (ndb->isopen == false || ndb->iswritable == false)
return false; return false;
ndb->wdb.flush();
for (Xapian::docid did = 1; did < ndb->updated.size(); ++did) { for (Xapian::docid did = 1; did < ndb->updated.size(); ++did) {
if (!ndb->updated[did]) { if (!ndb->updated[did]) {
try { try {
ndb->wdb.delete_document(did); ndb->wdb.delete_document(did);
LOGDEB(("Rcl::Db::purge: deleted document #%d\n", did)); LOGDEB(("Rcl::Db::purge: deleted document #%d\n", did));
} catch (const Xapian::DocNotFoundError &) { } catch (const Xapian::DocNotFoundError &) {
LOGDEB(("Rcl::Db::purge: document #%d not found\n", did));
} }
} }
} }

View File

@ -1,5 +1,4 @@
include ../mk/FreeBSD
CXXFLAGS = -I. -g
BIGLIB = ../lib/librcl.a BIGLIB = ../lib/librcl.a