index: add recollindex -f option to ignore skippedPaths/Names when using recollindex -i. Allows arbitrary (non-recoll) path handling for skipped subtree

This commit is contained in:
Jean-Francois Dockes 2011-05-15 22:19:55 +02:00
parent e29811cdb8
commit 478fb84ec4
5 changed files with 19 additions and 8 deletions

View File

@ -187,7 +187,7 @@ static bool matchesSkipped(const list<string>& tdl,
/** /**
* Index individual files, out of a full tree run. No database purging * Index individual files, out of a full tree run. No database purging
*/ */
bool FsIndexer::indexFiles(list<string>& files) bool FsIndexer::indexFiles(list<string>& files, ConfIndexer::IxFlag flag)
{ {
if (!init()) if (!init())
return false; return false;
@ -206,7 +206,8 @@ bool FsIndexer::indexFiles(list<string>& files)
walker.setSkippedNames(m_config->getSkippedNames()); walker.setSkippedNames(m_config->getSkippedNames());
// Check path against indexed areas and skipped names/paths // Check path against indexed areas and skipped names/paths
if (matchesSkipped(m_tdl, walker, *it)) { if (!(flag&ConfIndexer::IxFIgnoreSkip) &&
matchesSkipped(m_tdl, walker, *it)) {
it++; continue; it++; continue;
} }

View File

@ -22,6 +22,7 @@
using std::list; using std::list;
#endif #endif
#include "indexer.h"
#include "fstreewalk.h" #include "fstreewalk.h"
#include "rcldb.h" #include "rcldb.h"
@ -58,7 +59,8 @@ class FsIndexer : public FsTreeWalkerCB {
bool index(); bool index();
/** Index a list of files. No db cleaning or stemdb updating */ /** Index a list of files. No db cleaning or stemdb updating */
bool indexFiles(list<string> &files); bool indexFiles(list<string> &files, ConfIndexer::IxFlag f =
ConfIndexer::IxFNone);
/** Purge a list of files. */ /** Purge a list of files. */
bool purgeFiles(list<string> &files); bool purgeFiles(list<string> &files);

View File

@ -104,7 +104,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun)
return true; return true;
} }
bool ConfIndexer::indexFiles(std::list<string>& ifiles) bool ConfIndexer::indexFiles(std::list<string>& ifiles, IxFlag flag)
{ {
list<string> myfiles; list<string> myfiles;
for (list<string>::const_iterator it = ifiles.begin(); for (list<string>::const_iterator it = ifiles.begin();
@ -123,7 +123,7 @@ bool ConfIndexer::indexFiles(std::list<string>& ifiles)
if (!m_fsindexer) if (!m_fsindexer)
m_fsindexer = new FsIndexer(m_config, &m_db, m_updater); m_fsindexer = new FsIndexer(m_config, &m_db, m_updater);
if (m_fsindexer) if (m_fsindexer)
ret = m_fsindexer->indexFiles(myfiles); ret = m_fsindexer->indexFiles(myfiles, flag);
LOGDEB2(("ConfIndexer::indexFiles: fsindexer returned %d, " LOGDEB2(("ConfIndexer::indexFiles: fsindexer returned %d, "
"%d files remainining\n", ret, myfiles.size())); "%d files remainining\n", ret, myfiles.size()));

View File

@ -73,6 +73,9 @@ class ConfIndexer {
// Indexer types. Maybe we'll have something more dynamic one day // Indexer types. Maybe we'll have something more dynamic one day
enum ixType {IxTNone, IxTFs=1, IxTBeagleQueue=2, enum ixType {IxTNone, IxTFs=1, IxTBeagleQueue=2,
IxTAll = IxTFs | IxTBeagleQueue}; IxTAll = IxTFs | IxTBeagleQueue};
// Misc indexing flags
enum IxFlag {IxFNone = 0, IxFIgnoreSkip = 1};
/** Run indexers */ /** Run indexers */
bool index(bool resetbefore, ixType typestorun); bool index(bool resetbefore, ixType typestorun);
@ -91,7 +94,7 @@ class ConfIndexer {
static list<string> getStemmerNames(); static list<string> getStemmerNames();
/** Index a list of files. No db cleaning or stemdb updating */ /** Index a list of files. No db cleaning or stemdb updating */
bool indexFiles(std::list<string> &files); bool indexFiles(std::list<string> &files, IxFlag f = IxFNone);
/** Purge a list of files. */ /** Purge a list of files. */
bool purgeFiles(std::list<string> &files); bool purgeFiles(std::list<string> &files);

View File

@ -60,6 +60,7 @@ static int op_flags;
#define OPT_x 0x800 #define OPT_x 0x800
#define OPT_l 0x1000 #define OPT_l 0x1000
#define OPT_b 0x2000 #define OPT_b 0x2000
#define OPT_f 0x4000
// Globals for atexit cleanup // Globals for atexit cleanup
static ConfIndexer *confindexer; static ConfIndexer *confindexer;
@ -130,7 +131,9 @@ bool indexfiles(RclConfig *config, list<string> &filenames)
return true; return true;
if (!makeIndexer(config)) if (!makeIndexer(config))
return false; return false;
return confindexer->indexFiles(filenames); return confindexer->indexFiles(filenames, (op_flags&OPT_f) ?
ConfIndexer::IxFIgnoreSkip :
ConfIndexer::IxFNone);
} }
// Delete a list of files. Same comments about call contexts as indexfiles. // Delete a list of files. Same comments about call contexts as indexfiles.
@ -185,8 +188,9 @@ static const char usage [] =
#endif /* RCL_MONITOR */ #endif /* RCL_MONITOR */
"recollindex -e <filename [filename ...]>\n" "recollindex -e <filename [filename ...]>\n"
" Purge data for individual files. No stem database updates\n" " Purge data for individual files. No stem database updates\n"
"recollindex -i <filename [filename ...]>\n" "recollindex -i [-f] <filename [filename ...]>\n"
" Index individual files. No database purge or stem database updates\n" " Index individual files. No database purge or stem database updates\n"
" -f : ignore skippedPaths and skippedNames while doing this\n"
"recollindex -l\n" "recollindex -l\n"
" List available stemming languages\n" " List available stemming languages\n"
"recollindex -s <lang>\n" "recollindex -s <lang>\n"
@ -244,6 +248,7 @@ int main(int argc, const char **argv)
case 'D': op_flags |= OPT_D; break; case 'D': op_flags |= OPT_D; break;
#endif #endif
case 'e': op_flags |= OPT_e; break; case 'e': op_flags |= OPT_e; break;
case 'f': op_flags |= OPT_f; break;
case 'h': op_flags |= OPT_h; break; case 'h': op_flags |= OPT_h; break;
case 'i': op_flags |= OPT_i; break; case 'i': op_flags |= OPT_i; break;
case 'l': op_flags |= OPT_l; break; case 'l': op_flags |= OPT_l; break;