index: add skippedPathsFnmPathname variable to enable disabling the use of FNM_PATHNAME while matching in skippedPaths. Closes issue #67

This commit is contained in:
Jean-Francois Dockes
2011-11-30 16:36:51 +01:00
parent 2afc769c38
commit 3759c0b52d
8 changed files with 70 additions and 32 deletions
+13 -4
View File
@@ -43,6 +43,7 @@
#include "smallut.h"
#include "textsplit.h"
#include "readfile.h"
#include "fstreewalk.h"
#ifndef NO_NAMESPACES
using namespace std;
@@ -200,6 +201,12 @@ bool RclConfig::updateMainConfig()
m_rmtstate.init(this, 0, "indexedmimetypes");
return false;
}
delete m_conf;
m_conf = newconf;
m_skpnstate.init(this, m_conf, "skippedNames");
m_rmtstate.init(this, m_conf, "indexedmimetypes");
setKeyDir(cstr_null);
bool nocjk = false;
if (getConfParam("nocjk", &nocjk) && nocjk == true) {
@@ -218,10 +225,12 @@ bool RclConfig::updateMainConfig()
TextSplit::noNumbers();
}
delete m_conf;
m_conf = newconf;
m_skpnstate.init(this, m_conf, "skippedNames");
m_rmtstate.init(this, m_conf, "indexedmimetypes");
bool fnmpathname = true;
if (getConfParam("skippedPathsFnmPathname", &fnmpathname)
&& fnmpathname == false) {
FsTreeWalker::setNoFnmPathname();
}
return true;
}
+13 -6
View File
@@ -3441,12 +3441,19 @@ skippedNames = #* bin CVS Cache cache* caughtspam tmp .thumbnails .svn \
<programlisting>
skippedPaths = ~/somedir/&lowast;.txt
</programlisting>
<para>The values in the <literal>*skippedPaths</literal>
variables are currently matched with
<literal>fnmatch(3)</literal>, with the FNM_PATHNAME and
FNM_LEADING_DIR flags. This means that '/' characters must
be matched explicitely, which is probably
unfortunate.</para>
</listitem>
</varlistentry>
<varlistentry id="rcl.install.config.recollconf.skippedpathsfnmpathname">
<term><literal>skippedPathsFnmPathname</literal></term>
<listitem><para>The values in the
<literal>*skippedPaths</literal> variables are matched by
default with <literal>fnmatch(3)</literal>, with the
FNM_PATHNAME and FNM_LEADING_DIR flags. This means that '/'
characters must be matched explicitely. You can set
<literal>skippedPathsFnmPathname</literal> to 0 to disable
the use of FNM_PATHNAME (meaning that /*/dir3 will match
/dir1/dir2/dir3).</para>
</listitem>
</varlistentry>
+6
View File
@@ -29,6 +29,12 @@ skippedNames = #* bin CVS Cache cache* caughtspam tmp .thumbnails .svn \
# not set, the daemon uses skippedPaths.
#daemSkippedPaths =
# Recoll uses FNM_PATHNAME by default when matching skipped paths, which
# means that /dir1/dir2/dir3 is not matched by */dir3. Can't change the
# default now, but you can set the following variable to 0 to disable the
# use of FNM_PATHNAME (see fnmatch(3) man page)
# skippedPathsFnmPathname = 1
# 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)
+1 -1
View File
@@ -11,7 +11,7 @@ $(BIGLIB): force
cd $(depth)/lib;$(MAKE)
force:
FSTREEWALK_OBJS= trfstreewalk.o fstreewalk.o $(BIGLIB)
FSTREEWALK_OBJS= trfstreewalk.o $(BIGLIB)
trfstreewalk : $(FSTREEWALK_OBJS)
$(CXX) -o trfstreewalk $(FSTREEWALK_OBJS) $(LIBICONV) \
$(LIBSYS)
+1 -1
View File
@@ -1301,7 +1301,7 @@ int main(int argc, char **argv)
exit(1);
}
string udi;
make_udi(fn, cstr_null, udi);
make_udi(fn, "", udi);
sprintf(dic, "#whatever...\nmimetype = text/plain\nudi=%s\n",
udi.c_str());
string sdic;
+12 -2
View File
@@ -40,6 +40,8 @@
using namespace std;
#endif /* NO_NAMESPACES */
bool FsTreeWalker::o_useFnmPathname = true;
const int FsTreeWalker::FtwTravMask = FtwTravNatural|
FtwTravBreadth|FtwTravFilesThenDirs|FtwTravBreadthThenDepth;
@@ -153,7 +155,7 @@ bool FsTreeWalker::setSkippedPaths(const list<string> &paths)
}
bool FsTreeWalker::inSkippedPaths(const string& path, bool ckparents)
{
int fnmflags = FNM_PATHNAME;
int fnmflags = o_useFnmPathname ? FNM_PATHNAME : 0;
#ifdef FNM_LEADING_DIR
if (ckparents)
fnmflags |= FNM_LEADING_DIR;
@@ -420,6 +422,8 @@ FsTreeWalker::Status FsTreeWalker::iwalk(const string &top,
#include <iostream>
#include "rclinit.h"
#include "rclconfig.h"
#include "fstreewalk.h"
using namespace std;
@@ -542,7 +546,13 @@ int main(int argc, const char **argv)
opt |= FsTreeWalker::FtwTravFilesThenDirs;
else if (op_flags & OPT_m)
opt |= FsTreeWalker::FtwTravBreadthThenDepth;
string reason;
if (!recollinit(0, 0, reason)) {
fprintf(stderr, "Init failed: %s\n", reason.c_str());
exit(1);
}
FsTreeWalker walker(opt);
walker.setSkippedNames(patterns);
walker.setSkippedPaths(paths);
+12
View File
@@ -38,6 +38,18 @@ struct stat;
*/
class FsTreeWalker {
public:
// Global option to use FNM_PATHNAME when matching paths (for
// skippedPaths).
// We initially used FNM_PATHNAME, and we can't change it now
// (because of all the config files around). So add global option
// to not use the flag, which can be set from rclconfig by adding
// a value to the config file (skippedPathsNoFnmPathname)
static bool o_useFnmPathname;
static void setNoFnmPathname()
{
o_useFnmPathname = false;
}
// Flags for call to processone(). FtwDirEnter is used when
// entering a directory. FtwDirReturn is used when returning to it
// after processing a subdirectory.