diff --git a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp index b078da7a..8b0ec6a1 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.40 2006-12-20 13:12:49 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.41 2007-02-02 10:12:58 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -436,7 +436,7 @@ string RclConfig::getDbDir() } } LOGDEB1(("RclConfig::getDbDir: dbdir: [%s]\n", dbdir.c_str())); - return dbdir; + return path_canon(dbdir); } list RclConfig::getSkippedNames() @@ -446,16 +446,46 @@ list RclConfig::getSkippedNames() 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; +} + +list RclConfig::getSkippedPaths() +{ + list skpl; + string skipped; + if (getConfParam("skippedPaths", skipped)) { + stringToStrings(skipped, skpl); } + // Always add the dbdir and confdir to the skipped paths + skpl.push_back(getDbDir()); + skpl.push_back(getConfDir()); + for (list::iterator it = skpl.begin(); it != skpl.end(); it++) { + *it = path_tildexpand(*it); + *it = path_canon(*it); + } + skpl.sort(); + skpl.unique(); + return skpl; +} + +list RclConfig::getDaemSkippedPaths() +{ + list skpl = getSkippedPaths(); + + list dskpl; + string skipped; + if (getConfParam("daemSkippedPaths", skipped)) { + stringToStrings(skipped, dskpl); + } + + for (list::iterator it = dskpl.begin(); it != dskpl.end(); it++) { + *it = path_tildexpand(*it); + *it = path_canon(*it); + } + dskpl.sort(); + + skpl.merge(dskpl); + skpl.unique(); return skpl; } diff --git a/src/common/rclconfig.h b/src/common/rclconfig.h index ae0c7954..e7bcf706 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.30 2006-12-20 13:12:49 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: rclconfig.h,v 1.31 2007-02-02 10:12:58 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -82,6 +82,13 @@ class RclConfig { /** Get list of skipped names for current keydir */ list getSkippedNames(); + /** Get list of skipped paths patterns. Doesn't depend on the keydir */ + list getSkippedPaths(); + + /** Get list of skipped paths patterns, daemon version (may add some) + Doesn't depend on the keydir */ + list getDaemSkippedPaths(); + /** * Check if file name should be ignored because of suffix * diff --git a/src/index/indexer.cpp b/src/index/indexer.cpp index c7670f6f..64e9ebd6 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.50 2006-12-21 09:22:31 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: indexer.cpp,v 1.51 2007-02-02 10:12:58 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -82,10 +82,7 @@ bool DbIndexer::indexDb(bool resetbefore, list *topdirs) m_updater->status.dbtotdocs = m_db.docCnt(); } - // Always add dbdir and confdir to skipped paths. - m_walker.setSkippedPaths(list()); - m_walker.addSkippedPath(m_config->getConfDir()); - m_walker.addSkippedPath(m_dbdir); + m_walker.setSkippedPaths(m_config->getSkippedPaths()); for (list::const_iterator it = topdirs->begin(); it != topdirs->end(); it++) { diff --git a/src/index/rclmonrcv.cpp b/src/index/rclmonrcv.cpp index a3d8d810..44e896bf 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.9 2006-12-21 09:22:31 dockes Exp $ (C) 2006 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.10 2007-02-02 10:12:58 dockes Exp $ (C) 2006 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -128,13 +128,18 @@ void *rclMonRcvRun(void *q) // Walk the directory trees to add watches FsTreeWalker walker; - walker.addSkippedPath(queue->getConfig()->getConfDir()); + walker.setSkippedPaths(queue->getConfig()->getDaemSkippedPaths()); WalkCB walkcb(queue->getConfig(), mon, queue); for (list::iterator it = tdl.begin(); it != tdl.end(); it++) { queue->getConfig()->setKeyDir(*it); - // Adjust the skipped names according to config, and add the dbdir to - // skipped paths + // Adjust the skipped names according to config walker.setSkippedNames(queue->getConfig()->getSkippedNames()); + // Add the dbdir to skipped paths. Note that adding the dbdir + // is probably not useful as we'll probably never have + // multiple dbs per config file, and the global dbdir is + // included by + // config->getSkippedPaths(). Still, better to be safe here as + // config->including dbdir in the walk will get us into a loop walker.addSkippedPath(queue->getConfig()->getDbDir()); LOGDEB(("rclMonRcvRun: walking %s\n", it->c_str())); walker.walk(*it, walkcb); diff --git a/src/utils/fstreewalk.cpp b/src/utils/fstreewalk.cpp index e88a3f8f..f8cdd860 100644 --- a/src/utils/fstreewalk.cpp +++ b/src/utils/fstreewalk.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: fstreewalk.cpp,v 1.10 2006-12-21 09:22:31 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: fstreewalk.cpp,v 1.11 2007-02-02 10:12:58 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -90,11 +90,12 @@ bool FsTreeWalker::setSkippedNames(const list &patterns) return true; } -bool FsTreeWalker::addSkippedPath(const string& path) +bool FsTreeWalker::addSkippedPath(const string& ipath) { + string path = path_canon(ipath); if (find(data->skippedPaths.begin(), data->skippedPaths.end(), path) == data->skippedPaths.end()) - data->skippedPaths.push_back(path_canon(path)); + data->skippedPaths.push_back(path); return true; } bool FsTreeWalker::setSkippedPaths(const list &paths) @@ -181,16 +182,16 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top, data->logsyserr("stat", fn); continue; } - if (S_ISDIR(st.st_mode)) { - if (!data->skippedPaths.empty()) { - list::const_iterator it; - for (it = data->skippedPaths.begin(); - it != data->skippedPaths.end(); it++) { - if (fn == *it) - goto skip; - } + if (!data->skippedPaths.empty()) { + list::const_iterator it; + for (it = data->skippedPaths.begin(); + it != data->skippedPaths.end(); it++) { + if (fnmatch(it->c_str(), fn.c_str(), FNM_PATHNAME) == 0) + goto skip; } + } + if (S_ISDIR(st.st_mode)) { if (data->options & FtwNoRecurse) { status = cb.processone(fn, &st, FtwDirEnter); } else {