add skippedPaths and daemSkippedPaths config variables
This commit is contained in:
parent
68b25b750c
commit
fde963eb2e
@ -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<string> RclConfig::getSkippedNames()
|
||||
@ -446,16 +446,46 @@ list<string> 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<string> RclConfig::getSkippedPaths()
|
||||
{
|
||||
list<string> 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<string>::iterator it = skpl.begin(); it != skpl.end(); it++) {
|
||||
*it = path_tildexpand(*it);
|
||||
*it = path_canon(*it);
|
||||
}
|
||||
skpl.sort();
|
||||
skpl.unique();
|
||||
return skpl;
|
||||
}
|
||||
|
||||
list<string> RclConfig::getDaemSkippedPaths()
|
||||
{
|
||||
list<string> skpl = getSkippedPaths();
|
||||
|
||||
list<string> dskpl;
|
||||
string skipped;
|
||||
if (getConfParam("daemSkippedPaths", skipped)) {
|
||||
stringToStrings(skipped, dskpl);
|
||||
}
|
||||
|
||||
for (list<string>::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;
|
||||
}
|
||||
|
||||
|
||||
@ -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 <list>
|
||||
#include <string>
|
||||
@ -82,6 +82,13 @@ class RclConfig {
|
||||
/** Get list of skipped names for current keydir */
|
||||
list<string> getSkippedNames();
|
||||
|
||||
/** Get list of skipped paths patterns. Doesn't depend on the keydir */
|
||||
list<string> getSkippedPaths();
|
||||
|
||||
/** Get list of skipped paths patterns, daemon version (may add some)
|
||||
Doesn't depend on the keydir */
|
||||
list<string> getDaemSkippedPaths();
|
||||
|
||||
/**
|
||||
* Check if file name should be ignored because of suffix
|
||||
*
|
||||
|
||||
@ -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<string> *topdirs)
|
||||
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);
|
||||
m_walker.setSkippedPaths(m_config->getSkippedPaths());
|
||||
|
||||
for (list<string>::const_iterator it = topdirs->begin();
|
||||
it != topdirs->end(); it++) {
|
||||
|
||||
@ -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<string>::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);
|
||||
|
||||
@ -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<string> &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<string> &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<string>::const_iterator it;
|
||||
for (it = data->skippedPaths.begin();
|
||||
it != data->skippedPaths.end(); it++) {
|
||||
if (fn == *it)
|
||||
goto skip;
|
||||
}
|
||||
if (!data->skippedPaths.empty()) {
|
||||
list<string>::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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user