always skip indexing of confdir and dbdir. start index monitor with normal indexing pass

This commit is contained in:
dockes 2006-12-21 09:22:31 +00:00
parent 432509dd42
commit 4bce91b3d6
5 changed files with 44 additions and 11 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.49 2006-12-19 08:40:50 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: indexer.cpp,v 1.50 2006-12-21 09:22:31 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -82,6 +82,11 @@ bool DbIndexer::indexDb(bool resetbefore, list<string> *topdirs)
m_updater->status.dbtotdocs = m_db.docCnt(); m_updater->status.dbtotdocs = m_db.docCnt();
} }
// Always add dbdir and confdir to skipped paths.
m_walker.setSkippedPaths(list<string>());
m_walker.addSkippedPath(m_config->getConfDir());
m_walker.addSkippedPath(m_dbdir);
for (list<string>::const_iterator it = topdirs->begin(); for (list<string>::const_iterator it = topdirs->begin();
it != topdirs->end(); it++) { it != topdirs->end(); it++) {
LOGDEB(("DbIndexer::index: Indexing %s into %s\n", it->c_str(), LOGDEB(("DbIndexer::index: Indexing %s into %s\n", it->c_str(),

View File

@ -1,7 +1,7 @@
#include "autoconfig.h" #include "autoconfig.h"
#ifdef RCL_MONITOR #ifdef RCL_MONITOR
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.8 2006-11-07 16:51:45 dockes Exp $ (C) 2006 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.9 2006-12-21 09:22:31 dockes Exp $ (C) 2006 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -128,11 +128,14 @@ void *rclMonRcvRun(void *q)
// Walk the directory trees to add watches // Walk the directory trees to add watches
FsTreeWalker walker; FsTreeWalker walker;
walker.addSkippedPath(queue->getConfig()->getConfDir());
WalkCB walkcb(queue->getConfig(), mon, queue); WalkCB walkcb(queue->getConfig(), mon, queue);
for (list<string>::iterator it = tdl.begin(); it != tdl.end(); it++) { for (list<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
queue->getConfig()->setKeyDir(*it); queue->getConfig()->setKeyDir(*it);
// Adjust the skipped names according to config // Adjust the skipped names according to config, and add the dbdir to
// skipped paths
walker.setSkippedNames(queue->getConfig()->getSkippedNames()); walker.setSkippedNames(queue->getConfig()->getSkippedNames());
walker.addSkippedPath(queue->getConfig()->getDbDir());
LOGDEB(("rclMonRcvRun: walking %s\n", it->c_str())); LOGDEB(("rclMonRcvRun: walking %s\n", it->c_str()));
walker.walk(*it, walkcb); walker.walk(*it, walkcb);
} }

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.28 2006-12-20 09:41:37 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.29 2006-12-21 09:22:31 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -216,6 +216,7 @@ static int op_flags;
#define OPT_m 0x80 #define OPT_m 0x80
#define OPT_D 0x100 #define OPT_D 0x100
#define OPT_e 0x200 #define OPT_e 0x200
#define OPT_w 0x400
static const char usage [] = static const char usage [] =
"\n" "\n"
@ -253,6 +254,9 @@ Usage(void)
int main(int argc, const char **argv) int main(int argc, const char **argv)
{ {
string a_config; string a_config;
#ifdef RCL_MONITOR
int sleepsecs = 60;
#endif
thisprog = argv[0]; thisprog = argv[0];
argc--; argv++; argc--; argv++;
@ -277,6 +281,12 @@ int main(int argc, const char **argv)
case 's': op_flags |= OPT_s; break; case 's': op_flags |= OPT_s; break;
#ifdef RCL_USE_ASPELL #ifdef RCL_USE_ASPELL
case 'S': op_flags |= OPT_S; break; case 'S': op_flags |= OPT_S; break;
#endif
#ifdef RCL_MONITOR
case 'w': op_flags |= OPT_w; if (argc < 2) Usage();
if ((sscanf(*(++argv), "%d", &sleepsecs)) != 1)
Usage();
argc--; goto b1;
#endif #endif
case 'z': op_flags |= OPT_z; break; case 'z': op_flags |= OPT_z; break;
default: Usage(); break; default: Usage(); break;
@ -297,6 +307,7 @@ int main(int argc, const char **argv)
cerr << "Configuration problem: " << reason << endl; cerr << "Configuration problem: " << reason << endl;
exit(1); exit(1);
} }
bool rezero(op_flags & OPT_z);
if (op_flags & (OPT_i|OPT_e)) { if (op_flags & (OPT_i|OPT_e)) {
list<string> filenames; list<string> filenames;
@ -331,9 +342,16 @@ int main(int argc, const char **argv)
if (argc != 0) if (argc != 0)
Usage(); Usage();
if (!(op_flags&OPT_D)) { if (!(op_flags&OPT_D)) {
LOGDEB(("Daemonizing\n")); LOGDEB(("recollindex: daemonizing\n"));
daemon(0,0); daemon(0,0);
} }
if (sleepsecs > 0) {
LOGDEB(("recollindex: sleeping %d\n", sleepsecs));
sleep(sleepsecs);
}
confindexer = new ConfIndexer(config, &updater);
confindexer->index(rezero);
delete confindexer;
if (startMonitor(config, (op_flags&OPT_D)!=0)) if (startMonitor(config, (op_flags&OPT_D)!=0))
exit(0); exit(0);
exit(1); exit(1);
@ -350,7 +368,6 @@ int main(int argc, const char **argv)
} else { } else {
confindexer = new ConfIndexer(config, &updater); confindexer = new ConfIndexer(config, &updater);
bool rezero(op_flags & OPT_z);
exit(!confindexer->index(rezero)); exit(!confindexer->index(rezero));
} }
} }

View File

@ -1,4 +1,4 @@
# @(#$Id: mimemap,v 1.16 2006-09-05 09:52:23 dockes Exp $ (C) 2004 J.F.Dockes # @(#$Id: mimemap,v 1.17 2006-12-21 09:22:31 dockes Exp $ (C) 2004 J.F.Dockes
# Recoll: associations of file name extensions to mime types # Recoll: associations of file name extensions to mime types
.txt = text/plain .txt = text/plain
@ -69,7 +69,7 @@
recoll_noindex = .tar.gz .tgz .tar.bz2 .tbz .log.gz .md5 .map \ recoll_noindex = .tar.gz .tgz .tar.bz2 .tbz .log.gz .md5 .map \
.m4 .tcl .js .sh .pl .awk \ .m4 .tcl .js .sh .pl .awk \
.o .lib .dll .a \ .o .lib .dll .a \
.dat .bak .rdf .log .db .ini .msf \ .dat .bak .rdf .log .db .ini .msf .pid \
.gnm .gnumeric .tex \ .gnm .gnumeric .tex \
.gif .bmp .xpm \ .gif .bmp .xpm \
,v ~ # ,v ~ #

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: fstreewalk.cpp,v 1.9 2006-12-21 08:22:35 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: fstreewalk.cpp,v 1.10 2006-12-21 09:22:31 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -77,18 +77,24 @@ int FsTreeWalker::getErrCnt()
bool FsTreeWalker::addSkippedName(const string& pattern) bool FsTreeWalker::addSkippedName(const string& pattern)
{ {
data->skippedNames.push_back(pattern); if (find(data->skippedNames.begin(),
data->skippedNames.end(), pattern) == data->skippedNames.end())
data->skippedNames.push_back(pattern);
return true; return true;
} }
bool FsTreeWalker::setSkippedNames(const list<string> &patterns) bool FsTreeWalker::setSkippedNames(const list<string> &patterns)
{ {
data->skippedNames = patterns; data->skippedNames = patterns;
data->skippedNames.sort();
data->skippedNames.unique();
return true; return true;
} }
bool FsTreeWalker::addSkippedPath(const string& path) bool FsTreeWalker::addSkippedPath(const string& path)
{ {
data->skippedPaths.push_back(path_canon(path)); if (find(data->skippedPaths.begin(),
data->skippedPaths.end(), path) == data->skippedPaths.end())
data->skippedPaths.push_back(path_canon(path));
return true; return true;
} }
bool FsTreeWalker::setSkippedPaths(const list<string> &paths) bool FsTreeWalker::setSkippedPaths(const list<string> &paths)
@ -97,6 +103,8 @@ bool FsTreeWalker::setSkippedPaths(const list<string> &paths)
for (list<string>::iterator it = data->skippedPaths.begin(); for (list<string>::iterator it = data->skippedPaths.begin();
it != data->skippedPaths.end(); it++) it != data->skippedPaths.end(); it++)
*it = path_canon(*it); *it = path_canon(*it);
data->skippedPaths.sort();
data->skippedPaths.unique();
return true; return true;
} }