check for symlinks in the topdirs list. Generate diags in confIndexer
This commit is contained in:
parent
42cf4123d5
commit
e9d722e25c
@ -24,7 +24,7 @@
|
||||
Dockes</holder>
|
||||
</copyright>
|
||||
|
||||
<releaseinfo>$Id: usermanual.sgml,v 1.8 2006-03-30 10:31:03 dockes Exp $</releaseinfo>
|
||||
<releaseinfo>$Id: usermanual.sgml,v 1.9 2006-04-04 12:37:51 dockes Exp $</releaseinfo>
|
||||
|
||||
<abstract>
|
||||
<para>This document introduces full text search notions
|
||||
@ -817,9 +817,12 @@
|
||||
<variablelist>
|
||||
|
||||
<varlistentry><term><literal>topdirs</literal></term>
|
||||
<listitem><para>Specifies the list of directories to index
|
||||
(recursively).</para>
|
||||
</listitem>
|
||||
<listitem><para>Specifies the list of directories or files to
|
||||
index (recursively for directories). The indexer will not
|
||||
follow symbolic links inside the indexed trees. If an entry in
|
||||
the <literal>topdirs</literal> list is a symbolic link,
|
||||
indexation will not start and will generate an error.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry><term><literal>skippedNames</literal></term>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.28 2006-04-04 09:34:10 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.29 2006-04-04 12:37:51 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -89,8 +89,8 @@ bool DbIndexer::indexDb(bool resetbefore, list<string> *topdirs)
|
||||
|
||||
// Walk the directory tree
|
||||
if (m_walker.walk(*it, *this) != FsTreeWalker::FtwOk) {
|
||||
LOGERR(("DbIndexer::index: error while indexing %s\n",
|
||||
it->c_str()));
|
||||
LOGERR(("DbIndexer::index: error while indexing %s: %s\n",
|
||||
it->c_str(), m_walker.getReason().c_str()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -267,11 +267,13 @@ bool ConfIndexer::index(bool resetbefore)
|
||||
string topdirs;
|
||||
if (!m_config->getConfParam("topdirs", topdirs)) {
|
||||
LOGERR(("ConfIndexer::index: no top directories in configuration\n"));
|
||||
m_reason = "Top directory list (topdirs param.) not found in config";
|
||||
return false;
|
||||
}
|
||||
list<string> tdl; // List of directories to be indexed
|
||||
if (!stringToStrings(topdirs, tdl)) {
|
||||
LOGERR(("ConfIndexer::index: parse error for directory list\n"));
|
||||
m_reason = "Directory list parse error";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -285,10 +287,26 @@ bool ConfIndexer::index(bool resetbefore)
|
||||
for (dirit = tdl.begin(); dirit != tdl.end(); dirit++) {
|
||||
string dbdir;
|
||||
string doctopdir = path_tildexpand(*dirit);
|
||||
{ // Check top dirs. Must not be symlinks
|
||||
struct stat st;
|
||||
if (lstat(doctopdir.c_str(), &st) < 0) {
|
||||
LOGERR(("ConfIndexer::index: cant stat %s\n",
|
||||
doctopdir.c_str()));
|
||||
m_reason = string("Stat error for: ") + doctopdir;
|
||||
return false;
|
||||
}
|
||||
if (S_ISLNK(st.st_mode)) {
|
||||
LOGERR(("ConfIndexer::index: no symlinks allowed in topdirs: %s\n",
|
||||
doctopdir.c_str()));
|
||||
m_reason = doctopdir + "is a symbolic link";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
m_config->setKeyDir(doctopdir);
|
||||
if (!m_config->getConfParam("dbdir", dbdir)) {
|
||||
LOGERR(("ConfIndexer::index: no database directory in "
|
||||
"configuration for %s\n", doctopdir.c_str()));
|
||||
m_reason = string("No database directory set for ") + doctopdir;
|
||||
return false;
|
||||
}
|
||||
dbdir = path_tildexpand(dbdir);
|
||||
@ -315,6 +333,7 @@ bool ConfIndexer::index(bool resetbefore)
|
||||
m_dbindexer = new DbIndexer(m_config, dbit->first, m_updfunc);
|
||||
if (!m_dbindexer->indexDb(resetbefore, &dbit->second)) {
|
||||
deleteZ(m_dbindexer);
|
||||
m_reason = string("Failed indexing in ") + dbit->first;
|
||||
return false;
|
||||
}
|
||||
deleteZ(m_dbindexer);
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _INDEXER_H_INCLUDED_
|
||||
#define _INDEXER_H_INCLUDED_
|
||||
/* @(#$Id: indexer.h,v 1.12 2006-04-04 09:34:11 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: indexer.h,v 1.13 2006-04-04 12:37:51 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
@ -53,10 +53,12 @@ class ConfIndexer {
|
||||
virtual ~ConfIndexer();
|
||||
/** Worker function: doe the actual indexing */
|
||||
bool index(bool resetbefore = false);
|
||||
const string &getReason() {return m_reason;}
|
||||
private:
|
||||
RclConfig *m_config;
|
||||
DbIndexer *m_dbindexer; // Object to process directories for a given db
|
||||
DbIxStatusUpdater *m_updfunc;
|
||||
string m_reason;
|
||||
};
|
||||
|
||||
/** Index things into one database
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user