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>
|
Dockes</holder>
|
||||||
</copyright>
|
</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>
|
<abstract>
|
||||||
<para>This document introduces full text search notions
|
<para>This document introduces full text search notions
|
||||||
@ -817,9 +817,12 @@
|
|||||||
<variablelist>
|
<variablelist>
|
||||||
|
|
||||||
<varlistentry><term><literal>topdirs</literal></term>
|
<varlistentry><term><literal>topdirs</literal></term>
|
||||||
<listitem><para>Specifies the list of directories to index
|
<listitem><para>Specifies the list of directories or files to
|
||||||
(recursively).</para>
|
index (recursively for directories). The indexer will not
|
||||||
</listitem>
|
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>
|
||||||
|
|
||||||
<varlistentry><term><literal>skippedNames</literal></term>
|
<varlistentry><term><literal>skippedNames</literal></term>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#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
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
// Walk the directory tree
|
||||||
if (m_walker.walk(*it, *this) != FsTreeWalker::FtwOk) {
|
if (m_walker.walk(*it, *this) != FsTreeWalker::FtwOk) {
|
||||||
LOGERR(("DbIndexer::index: error while indexing %s\n",
|
LOGERR(("DbIndexer::index: error while indexing %s: %s\n",
|
||||||
it->c_str()));
|
it->c_str(), m_walker.getReason().c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,11 +267,13 @@ bool ConfIndexer::index(bool resetbefore)
|
|||||||
string topdirs;
|
string topdirs;
|
||||||
if (!m_config->getConfParam("topdirs", topdirs)) {
|
if (!m_config->getConfParam("topdirs", topdirs)) {
|
||||||
LOGERR(("ConfIndexer::index: no top directories in configuration\n"));
|
LOGERR(("ConfIndexer::index: no top directories in configuration\n"));
|
||||||
|
m_reason = "Top directory list (topdirs param.) not found in config";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
list<string> tdl; // List of directories to be indexed
|
list<string> tdl; // List of directories to be indexed
|
||||||
if (!stringToStrings(topdirs, tdl)) {
|
if (!stringToStrings(topdirs, tdl)) {
|
||||||
LOGERR(("ConfIndexer::index: parse error for directory list\n"));
|
LOGERR(("ConfIndexer::index: parse error for directory list\n"));
|
||||||
|
m_reason = "Directory list parse error";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,10 +287,26 @@ bool ConfIndexer::index(bool resetbefore)
|
|||||||
for (dirit = tdl.begin(); dirit != tdl.end(); dirit++) {
|
for (dirit = tdl.begin(); dirit != tdl.end(); dirit++) {
|
||||||
string dbdir;
|
string dbdir;
|
||||||
string doctopdir = path_tildexpand(*dirit);
|
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);
|
m_config->setKeyDir(doctopdir);
|
||||||
if (!m_config->getConfParam("dbdir", dbdir)) {
|
if (!m_config->getConfParam("dbdir", dbdir)) {
|
||||||
LOGERR(("ConfIndexer::index: no database directory in "
|
LOGERR(("ConfIndexer::index: no database directory in "
|
||||||
"configuration for %s\n", doctopdir.c_str()));
|
"configuration for %s\n", doctopdir.c_str()));
|
||||||
|
m_reason = string("No database directory set for ") + doctopdir;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dbdir = path_tildexpand(dbdir);
|
dbdir = path_tildexpand(dbdir);
|
||||||
@ -315,6 +333,7 @@ bool ConfIndexer::index(bool resetbefore)
|
|||||||
m_dbindexer = new DbIndexer(m_config, dbit->first, m_updfunc);
|
m_dbindexer = new DbIndexer(m_config, dbit->first, m_updfunc);
|
||||||
if (!m_dbindexer->indexDb(resetbefore, &dbit->second)) {
|
if (!m_dbindexer->indexDb(resetbefore, &dbit->second)) {
|
||||||
deleteZ(m_dbindexer);
|
deleteZ(m_dbindexer);
|
||||||
|
m_reason = string("Failed indexing in ") + dbit->first;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
deleteZ(m_dbindexer);
|
deleteZ(m_dbindexer);
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef _INDEXER_H_INCLUDED_
|
#ifndef _INDEXER_H_INCLUDED_
|
||||||
#define _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 <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
@ -53,10 +53,12 @@ class ConfIndexer {
|
|||||||
virtual ~ConfIndexer();
|
virtual ~ConfIndexer();
|
||||||
/** Worker function: doe the actual indexing */
|
/** Worker function: doe the actual indexing */
|
||||||
bool index(bool resetbefore = false);
|
bool index(bool resetbefore = false);
|
||||||
|
const string &getReason() {return m_reason;}
|
||||||
private:
|
private:
|
||||||
RclConfig *m_config;
|
RclConfig *m_config;
|
||||||
DbIndexer *m_dbindexer; // Object to process directories for a given db
|
DbIndexer *m_dbindexer; // Object to process directories for a given db
|
||||||
DbIxStatusUpdater *m_updfunc;
|
DbIxStatusUpdater *m_updfunc;
|
||||||
|
string m_reason;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Index things into one database
|
/** Index things into one database
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user