From 5a3244a5a837919e6b64231d5966c576343e863f Mon Sep 17 00:00:00 2001 From: dockes Date: Thu, 30 Aug 2007 09:01:52 +0000 Subject: [PATCH] add followLinks option --- src/doc/user/usermanual.sgml | 7 +++++-- src/index/indexer.cpp | 11 ++++++++++- src/index/indexer.h | 6 +++--- src/index/rclmonrcv.cpp | 10 +++++++++- src/sampleconf/recoll.conf.in | 7 ++++++- src/utils/fstreewalk.cpp | 9 ++++++++- src/utils/fstreewalk.h | 5 ++++- 7 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/doc/user/usermanual.sgml b/src/doc/user/usermanual.sgml index d20c119c..46ffddfe 100644 --- a/src/doc/user/usermanual.sgml +++ b/src/doc/user/usermanual.sgml @@ -24,7 +24,7 @@ Dockes - $Id: usermanual.sgml,v 1.49 2007-08-30 08:39:04 dockes Exp $ + $Id: usermanual.sgml,v 1.50 2007-08-30 09:00:22 dockes Exp $ This document introduces full text search notions @@ -1845,7 +1845,10 @@ skippedPaths = ~/somedir/*.txt symbolic links while walking the file tree. The default is to ignore symbolic links to avoid multiple indexing of linked files. No effort is made to avoid duplication when - this option is set to true.. + this option is set to true. This option can be set + individually for each of the topdirs + members by using sections. It can not be changed below the + topdirs level. diff --git a/src/index/indexer.cpp b/src/index/indexer.cpp index aa0af248..f084085f 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.61 2007-08-28 08:12:58 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: indexer.cpp,v 1.62 2007-08-30 09:01:52 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -97,6 +97,15 @@ bool DbIndexer::indexDb(bool resetbefore, list *topdirs) // Set the current directory in config so that subsequent // getConfParams() will get local values m_config->setKeyDir(*it); + + // Adjust the "follow symlinks" option + bool follow; + if (m_config->getConfParam("followLinks", &follow) && follow) { + m_walker.setOpts(FsTreeWalker::FtwFollow); + } else { + m_walker.setOpts(FsTreeWalker::FtwOptNone); + } + int abslen; if (m_config->getConfParam("idxabsmlen", &abslen)) m_db.setAbstractParams(abslen, -1, -1); diff --git a/src/index/indexer.h b/src/index/indexer.h index 008bc7fa..34293258 100644 --- a/src/index/indexer.h +++ b/src/index/indexer.h @@ -16,7 +16,7 @@ */ #ifndef _INDEXER_H_INCLUDED_ #define _INDEXER_H_INCLUDED_ -/* @(#$Id: indexer.h,v 1.24 2007-07-10 09:23:28 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: indexer.h,v 1.25 2007-08-30 09:01:52 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -96,8 +96,8 @@ class DbIndexer : public FsTreeWalkerCB { const string &dbd, // Place where the db lives DbIxStatusUpdater *updfunc = 0 // status updater callback ) - : m_config(cnf), m_dbdir(dbd), m_updater(updfunc) { - } + : m_config(cnf), m_dbdir(dbd), m_updater(updfunc) + {} virtual ~DbIndexer(); diff --git a/src/index/rclmonrcv.cpp b/src/index/rclmonrcv.cpp index e5b938d6..fc73c85e 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.12 2007-07-12 10:53:07 dockes Exp $ (C) 2006 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclmonrcv.cpp,v 1.13 2007-08-30 09:01:52 dockes Exp $ (C) 2006 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -134,6 +134,14 @@ void *rclMonRcvRun(void *q) WalkCB walkcb(queue->getConfig(), mon, queue); for (list::iterator it = tdl.begin(); it != tdl.end(); it++) { queue->getConfig()->setKeyDir(*it); + // Adjust the follow symlinks options + bool follow; + if (queue->getConfig()->getConfParam("followLinks", &follow) && + follow) { + walker.setOpts(FsTreeWalker::FtwFollow); + } else { + walker.setOpts(FsTreeWalker::FtwOptNone); + } // Adjust the skipped names according to config walker.setSkippedNames(queue->getConfig()->getSkippedNames()); // Add the dbdir to skipped paths. Note that adding the dbdir diff --git a/src/sampleconf/recoll.conf.in b/src/sampleconf/recoll.conf.in index b2e2011d..6a091caf 100644 --- a/src/sampleconf/recoll.conf.in +++ b/src/sampleconf/recoll.conf.in @@ -1,4 +1,4 @@ -# @(#$Id: recoll.conf.in,v 1.20 2007-08-26 13:34:06 dockes Exp $ (C) 2004 J.F.Dockes +# @(#$Id: recoll.conf.in,v 1.21 2007-08-30 09:01:52 dockes Exp $ (C) 2004 J.F.Dockes # # Recoll default configuration file. This typically lives in # @prefix@/share/recoll/examples and provides default values. You can @@ -24,6 +24,11 @@ skippedNames = #* bin CVS Cache cache* caughtspam tmp .thumbnails .svn \ # not set, the daemon uses skippedPaths. #daemSkippedPaths = +# Option to follow symbolic links. We normally don't, to avoid duplicated +# indexing (in any case, no effort is made to identify or avoid multiple +# indexing of linked files) +# followLinks = 0 + # Debug messages. 3 is errors/warnings only. 4 would be quite verbose. loglevel = 3 logfilename = stderr diff --git a/src/utils/fstreewalk.cpp b/src/utils/fstreewalk.cpp index 6823ce8e..b7cf5844 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.13 2007-08-28 08:08:38 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: fstreewalk.cpp,v 1.14 2007-08-30 09:01:52 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -65,6 +65,13 @@ FsTreeWalker::~FsTreeWalker() delete data; } +void FsTreeWalker::setOpts(Options opts) +{ + if (data) { + data->options = opts; + } +} + string FsTreeWalker::getReason() { return data->reason.str(); diff --git a/src/utils/fstreewalk.h b/src/utils/fstreewalk.h index 74b08aa5..6eda7a20 100644 --- a/src/utils/fstreewalk.h +++ b/src/utils/fstreewalk.h @@ -16,7 +16,7 @@ */ #ifndef _FSTREEWALK_H_INCLUDED_ #define _FSTREEWALK_H_INCLUDED_ -/* @(#$Id: fstreewalk.h,v 1.8 2007-08-28 08:08:39 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: fstreewalk.h,v 1.9 2007-08-30 09:01:52 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -46,6 +46,9 @@ class FsTreeWalker { FsTreeWalker(Options opts = FtwOptNone); ~FsTreeWalker(); + + void setOpts(Options opts); + /** * Begin file system walk. * @param dir is not checked against the ignored patterns (this is