make tmpdir only once
This commit is contained in:
parent
74205c0e82
commit
72aca22c7e
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.42 2006-10-25 10:52:02 dockes Exp $ (C) 2004 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.43 2006-10-25 11:50:49 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
|
||||||
@ -163,10 +163,11 @@ bool DbIndexer::createStemmingDatabases()
|
|||||||
|
|
||||||
bool DbIndexer::init(bool resetbefore)
|
bool DbIndexer::init(bool resetbefore)
|
||||||
{
|
{
|
||||||
if (!maketmpdir(m_tmpdir)) {
|
if (m_tmpdir.empty() || access(m_tmpdir.c_str(), 0) < 0)
|
||||||
LOGERR(("DbIndexer: cannot create temporary directory\n"));
|
if (!maketmpdir(m_tmpdir)) {
|
||||||
return false;
|
LOGERR(("DbIndexer: cannot create temporary directory\n"));
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
if (!m_db.open(m_dbdir, resetbefore ? Rcl::Db::DbTrunc : Rcl::Db::DbUpd)) {
|
if (!m_db.open(m_dbdir, resetbefore ? Rcl::Db::DbTrunc : Rcl::Db::DbUpd)) {
|
||||||
LOGERR(("DbIndexer: error opening database in %s\n", m_dbdir.c_str()));
|
LOGERR(("DbIndexer: error opening database in %s\n", m_dbdir.c_str()));
|
||||||
return false;
|
return false;
|
||||||
@ -217,8 +218,7 @@ bool DbIndexer::createAspellDict()
|
|||||||
*/
|
*/
|
||||||
bool DbIndexer::indexFiles(const list<string> &filenames)
|
bool DbIndexer::indexFiles(const list<string> &filenames)
|
||||||
{
|
{
|
||||||
if (!init())
|
bool called_init = false;
|
||||||
return false;
|
|
||||||
|
|
||||||
list<string>::const_iterator it;
|
list<string>::const_iterator it;
|
||||||
for (it = filenames.begin(); it != filenames.end(); it++) {
|
for (it = filenames.begin(); it != filenames.end(); it++) {
|
||||||
@ -233,6 +233,9 @@ bool DbIndexer::indexFiles(const list<string> &filenames)
|
|||||||
strerror(errno)));
|
strerror(errno)));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we get to indexing directory names one day, will need to test
|
||||||
|
// against dbdir here to avoid modification loops (with rclmon).
|
||||||
if (!S_ISREG(stb.st_mode)) {
|
if (!S_ISREG(stb.st_mode)) {
|
||||||
LOGDEB2(("DbIndexer::indexFiles: %s: not a regular file\n",
|
LOGDEB2(("DbIndexer::indexFiles: %s: not a regular file\n",
|
||||||
it->c_str()));
|
it->c_str()));
|
||||||
@ -256,7 +259,12 @@ bool DbIndexer::indexFiles(const list<string> &filenames)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Defer opening db until really needed.
|
||||||
|
if (!called_init) {
|
||||||
|
if (!init())
|
||||||
|
return false;
|
||||||
|
called_init = true;
|
||||||
|
}
|
||||||
if (processone(*it, &stb, FsTreeWalker::FtwRegular) !=
|
if (processone(*it, &stb, FsTreeWalker::FtwRegular) !=
|
||||||
FsTreeWalker::FtwOk) {
|
FsTreeWalker::FtwOk) {
|
||||||
LOGERR(("DbIndexer::indexFiles: processone failed\n"));
|
LOGERR(("DbIndexer::indexFiles: processone failed\n"));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user