From d8f8dd851ee87082a206335f3e4d512000e34f06 Mon Sep 17 00:00:00 2001 From: dockes Date: Tue, 24 Oct 2006 09:09:36 +0000 Subject: [PATCH] centralize skippedNames computation to add dbdir always --- src/common/rclconfig.cpp | 22 +++++++++++++++++++++- src/common/rclconfig.h | 5 ++++- src/index/indexer.cpp | 17 ++++------------- src/index/rclmonrcv.cpp | 10 ++-------- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp index a443baec..eb425af1 100644 --- a/src/common/rclconfig.cpp +++ b/src/common/rclconfig.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.31 2006-10-16 15:33:08 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.32 2006-10-24 09:09:36 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -313,6 +313,26 @@ string RclConfig::getDbDir() return dbdir; } +list RclConfig::getSkippedNames() +{ + list skpl; + string skipped; + if (getConfParam("skippedNames", skipped)) { + stringToStrings(skipped, skpl); + } + // If current keydir is dbdir's ancestor, add dbdir name to skipped + // This is mainly for the real-time monitor that will otherwise go + // into a loop + // We'd prefer to do it for the direct ancestor only, but getSkippedNames() + // is only called for the topdirs, so this doesn't work + string kd = path_canon(getKeyDir()); + string dbd = path_canon(getDbDir()); + if (dbd.find(kd) == 0) { + skpl.push_back(path_getsimple(dbd)); + } + return skpl; +} + // Look up an executable filter. We look in $RECOLL_FILTERSDIR, // filtersdir in config file, then let the system use the PATH diff --git a/src/common/rclconfig.h b/src/common/rclconfig.h index 8460d488..73483dff 100644 --- a/src/common/rclconfig.h +++ b/src/common/rclconfig.h @@ -16,7 +16,7 @@ */ #ifndef _RCLCONFIG_H_INCLUDED_ #define _RCLCONFIG_H_INCLUDED_ -/* @(#$Id: rclconfig.h,v 1.23 2006-10-16 15:33:08 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: rclconfig.h,v 1.24 2006-10-24 09:09:36 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -74,6 +74,9 @@ class RclConfig { /** Get database directory */ string getDbDir(); + /** Get list of skipped names for current keydir */ + list getSkippedNames(); + /** * Get list of ignored suffixes from mimemap * diff --git a/src/index/indexer.cpp b/src/index/indexer.cpp index 5b7dbf89..608dcafa 100644 --- a/src/index/indexer.cpp +++ b/src/index/indexer.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: indexer.cpp,v 1.39 2006-10-22 14:47:13 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: indexer.cpp,v 1.40 2006-10-24 09:09:36 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -96,13 +96,7 @@ bool DbIndexer::indexDb(bool resetbefore, list *topdirs) // Set up skipped patterns for this subtree. This probably should be // done in the directory change code in processone() instead. - m_walker.clearSkippedNames(); - string skipped; - if (m_config->getConfParam("skippedNames", skipped)) { - list skpl; - stringToStrings(skipped, skpl); - m_walker.setSkippedNames(skpl); - } + m_walker.setSkippedNames(m_config->getSkippedNames()); // Walk the directory tree if (m_walker.walk(*it, *this) != FsTreeWalker::FtwOk) { @@ -238,11 +232,8 @@ bool DbIndexer::indexFiles(const list &filenames) static list skpl; if (lstdir.compare(dir)) { LOGDEB(("Recomputing list of skipped names\n")); - string skipped; - if (m_config->getConfParam("skippedNames", skipped)) { - stringToStrings(skipped, skpl); - lstdir = dir; - } + skpl = m_config->getSkippedNames(); + lstdir = dir; } if (!skpl.empty()) { list::const_iterator skit; diff --git a/src/index/rclmonrcv.cpp b/src/index/rclmonrcv.cpp index 6f9c77ce..322a0eb3 100644 --- a/src/index/rclmonrcv.cpp +++ b/src/index/rclmonrcv.cpp @@ -1,7 +1,7 @@ #include "autoconfig.h" #ifdef RCL_MONITOR #ifndef lint -static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.5 2006-10-23 15:01:12 dockes Exp $ (C) 2006 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.6 2006-10-24 09:09:36 dockes Exp $ (C) 2006 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -129,13 +129,7 @@ void *rclMonRcvRun(void *q) for (list::iterator it = tdl.begin(); it != tdl.end(); it++) { queue->getConfig()->setKeyDir(*it); // Adjust the skipped names according to config - walker.clearSkippedNames(); - string skipped; - if (queue->getConfig()->getConfParam("skippedNames", skipped)) { - list skpl; - stringToStrings(skipped, skpl); - walker.setSkippedNames(skpl); - } + walker.setSkippedNames(queue->getConfig()->getSkippedNames()); LOGDEB(("rclMonRcvRun: walking %s\n", it->c_str())); walker.walk(*it, walkcb); }