|
a/src/index/recollindex.cpp |
|
b/src/index/recollindex.cpp |
|
... |
|
... |
40 |
#include "rclmon.h"
|
40 |
#include "rclmon.h"
|
41 |
#include "x11mon.h"
|
41 |
#include "x11mon.h"
|
42 |
#include "cancelcheck.h"
|
42 |
#include "cancelcheck.h"
|
43 |
#include "rcldb.h"
|
43 |
#include "rcldb.h"
|
44 |
#include "beaglequeue.h"
|
44 |
#include "beaglequeue.h"
|
|
|
45 |
#include "recollindex.h"
|
|
|
46 |
#include "fsindexer.h"
|
45 |
|
47 |
|
46 |
// Globals for atexit cleanup
|
48 |
// Globals for atexit cleanup
|
47 |
static ConfIndexer *confindexer;
|
49 |
static ConfIndexer *confindexer;
|
48 |
static DbIndexer *dbindexer;
|
50 |
static FsIndexer *fsindexer;
|
49 |
|
51 |
|
50 |
// This is set as an atexit routine,
|
52 |
// This is set as an atexit routine,
|
51 |
static void cleanup()
|
53 |
static void cleanup()
|
52 |
{
|
54 |
{
|
53 |
deleteZ(confindexer);
|
55 |
deleteZ(confindexer);
|
54 |
deleteZ(dbindexer);
|
56 |
deleteZ(fsindexer);
|
55 |
}
|
57 |
}
|
56 |
|
58 |
|
57 |
// Global stop request flag. This is checked in a number of place in the
|
59 |
// Global stop request flag. This is checked in a number of place in the
|
58 |
// indexing routines.
|
60 |
// indexing routines.
|
59 |
int stopindexing;
|
61 |
int stopindexing;
|
|
... |
|
... |
77 |
LOGDEB(("Got signal, registering stop request\n"));
|
79 |
LOGDEB(("Got signal, registering stop request\n"));
|
78 |
CancelCheck::instance().setCancel();
|
80 |
CancelCheck::instance().setCancel();
|
79 |
stopindexing = 1;
|
81 |
stopindexing = 1;
|
80 |
}
|
82 |
}
|
81 |
|
83 |
|
82 |
static bool makeDbIndexer(RclConfig *config)
|
84 |
static bool makeFsIndexer(RclConfig *config)
|
83 |
{
|
85 |
{
|
84 |
if (!dbindexer)
|
86 |
if (!fsindexer)
|
85 |
dbindexer = new DbIndexer(config, &updater);
|
87 |
fsindexer = new FsIndexer(config, &updater);
|
86 |
return dbindexer ? true : false;
|
88 |
return fsindexer ? true : false;
|
87 |
}
|
89 |
}
|
88 |
|
90 |
|
89 |
// The list of top directories/files wont change during program run,
|
91 |
// The list of top directories/files wont change during program run,
|
90 |
// let's cache it:
|
92 |
// let's cache it:
|
91 |
static list<string> o_tdl;
|
93 |
static list<string> o_tdl;
|
|
... |
|
... |
93 |
// Index a list of files. We just check that they belong to one of the
|
95 |
// Index a list of files. We just check that they belong to one of the
|
94 |
// topdirs subtrees, and call the indexer method.
|
96 |
// topdirs subtrees, and call the indexer method.
|
95 |
//
|
97 |
//
|
96 |
// This is called either from the command line or from the monitor. In
|
98 |
// This is called either from the command line or from the monitor. In
|
97 |
// this case we're called repeatedly in the same process, and the
|
99 |
// this case we're called repeatedly in the same process, and the
|
98 |
// dbIndexer is only created once by makeDbIndexer (but the db is
|
100 |
// fsindexer is only created once by makeFsIndexer (but the db is
|
99 |
// flushed anyway)
|
101 |
// flushed anyway)
|
100 |
bool indexfiles(RclConfig *config, const list<string> &filenames)
|
102 |
bool indexfiles(RclConfig *config, const list<string> &filenames)
|
101 |
{
|
103 |
{
|
102 |
if (filenames.empty())
|
104 |
if (filenames.empty())
|
103 |
return true;
|
105 |
return true;
|
|
... |
|
... |
137 |
// one database per config, so we set the keydir from the first
|
139 |
// one database per config, so we set the keydir from the first
|
138 |
// file (which is not really needed...), create the indexer/db and
|
140 |
// file (which is not really needed...), create the indexer/db and
|
139 |
// go:
|
141 |
// go:
|
140 |
config->setKeyDir(path_getfather(*myfiles.begin()));
|
142 |
config->setKeyDir(path_getfather(*myfiles.begin()));
|
141 |
|
143 |
|
142 |
if (!makeDbIndexer(config))
|
144 |
if (!makeFsIndexer(config))
|
143 |
return false;
|
145 |
return false;
|
144 |
|
146 |
|
145 |
return dbindexer->indexFiles(myfiles);
|
147 |
return fsindexer->indexFiles(myfiles);
|
146 |
}
|
148 |
}
|
147 |
|
149 |
|
148 |
// Delete a list of files. Same comments about call contexts as indexfiles.
|
150 |
// Delete a list of files. Same comments about call contexts as indexfiles.
|
149 |
bool purgefiles(RclConfig *config, const list<string> &filenames)
|
151 |
bool purgefiles(RclConfig *config, const list<string> &filenames)
|
150 |
{
|
152 |
{
|
|
... |
|
... |
171 |
// one database per config, so we set the keydir from the first
|
173 |
// one database per config, so we set the keydir from the first
|
172 |
// file (which is not really needed...), create the indexer/db and
|
174 |
// file (which is not really needed...), create the indexer/db and
|
173 |
// go:
|
175 |
// go:
|
174 |
config->setKeyDir(path_getfather(*myfiles.begin()));
|
176 |
config->setKeyDir(path_getfather(*myfiles.begin()));
|
175 |
|
177 |
|
176 |
if (!makeDbIndexer(config))
|
178 |
if (!makeFsIndexer(config))
|
177 |
return false;
|
179 |
return false;
|
178 |
return dbindexer->purgeFiles(myfiles);
|
180 |
return fsindexer->purgeFiles(myfiles);
|
179 |
}
|
181 |
}
|
180 |
|
182 |
|
181 |
// Create stemming and spelling databases
|
183 |
// Create stemming and spelling databases
|
182 |
bool createAuxDbs(RclConfig *config)
|
184 |
bool createAuxDbs(RclConfig *config)
|
183 |
{
|
185 |
{
|
184 |
if (!makeDbIndexer(config))
|
186 |
if (!makeFsIndexer(config))
|
185 |
return false;
|
187 |
return false;
|
186 |
|
188 |
|
187 |
if (!dbindexer->createStemmingDatabases())
|
189 |
if (!fsindexer->createStemmingDatabases())
|
188 |
return false;
|
190 |
return false;
|
189 |
|
191 |
|
190 |
if (!dbindexer->createAspellDict())
|
192 |
if (!fsindexer->createAspellDict())
|
191 |
return false;
|
193 |
return false;
|
192 |
|
194 |
|
193 |
return true;
|
195 |
return true;
|
194 |
}
|
196 |
}
|
195 |
|
197 |
|
196 |
// Create additional stem database
|
198 |
// Create additional stem database
|
197 |
static bool createstemdb(RclConfig *config, const string &lang)
|
199 |
static bool createstemdb(RclConfig *config, const string &lang)
|
198 |
{
|
200 |
{
|
199 |
if (!makeDbIndexer(config))
|
201 |
if (!makeFsIndexer(config))
|
200 |
return false;
|
202 |
return false;
|
201 |
return dbindexer->createStemDb(lang);
|
203 |
return fsindexer->createStemDb(lang);
|
202 |
}
|
204 |
}
|
203 |
|
205 |
|
204 |
static const char *thisprog;
|
206 |
static const char *thisprog;
|
205 |
static int op_flags;
|
207 |
static int op_flags;
|
206 |
#define OPT_MOINS 0x1
|
208 |
#define OPT_MOINS 0x1
|
|
... |
|
... |
350 |
exit(!purgefiles(config, filenames));
|
352 |
exit(!purgefiles(config, filenames));
|
351 |
|
353 |
|
352 |
} else if (op_flags & OPT_l) {
|
354 |
} else if (op_flags & OPT_l) {
|
353 |
if (argc != 0)
|
355 |
if (argc != 0)
|
354 |
Usage();
|
356 |
Usage();
|
355 |
list<string> stemmers = DbIndexer::getStemmerNames();
|
357 |
list<string> stemmers = FsIndexer::getStemmerNames();
|
356 |
for (list<string>::const_iterator it = stemmers.begin();
|
358 |
for (list<string>::const_iterator it = stemmers.begin();
|
357 |
it != stemmers.end(); it++) {
|
359 |
it != stemmers.end(); it++) {
|
358 |
cout << *it << endl;
|
360 |
cout << *it << endl;
|
359 |
}
|
361 |
}
|
360 |
exit(0);
|
362 |
exit(0);
|
|
... |
|
... |
393 |
exit(monret == false);
|
395 |
exit(monret == false);
|
394 |
#endif // MONITOR
|
396 |
#endif // MONITOR
|
395 |
|
397 |
|
396 |
#ifdef RCL_USE_ASPELL
|
398 |
#ifdef RCL_USE_ASPELL
|
397 |
} else if (op_flags & OPT_S) {
|
399 |
} else if (op_flags & OPT_S) {
|
398 |
if (!makeDbIndexer(config))
|
400 |
if (!makeFsIndexer(config))
|
399 |
exit(1);
|
401 |
exit(1);
|
400 |
exit(!dbindexer->createAspellDict());
|
402 |
exit(!fsindexer->createAspellDict());
|
401 |
#endif // ASPELL
|
403 |
#endif // ASPELL
|
402 |
} else if (op_flags & OPT_b) {
|
404 |
} else if (op_flags & OPT_b) {
|
403 |
BeagleQueueIndexer beagler(config);
|
405 |
BeagleQueueIndexer beagler(config);
|
404 |
bool status = beagler.processqueue();
|
406 |
bool status = beagler.processqueue();
|
405 |
return !status;
|
407 |
return !status;
|