|
a/src/index/indexer.cpp |
|
b/src/index/indexer.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.44 2006-11-07 06:41:44 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.45 2006-11-30 13:38:44 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
159 |
}
|
159 |
}
|
160 |
}
|
160 |
}
|
161 |
return true;
|
161 |
return true;
|
162 |
}
|
162 |
}
|
163 |
|
163 |
|
164 |
bool DbIndexer::init(bool resetbefore)
|
164 |
bool DbIndexer::init(bool resetbefore, bool rdonly)
|
165 |
{
|
165 |
{
|
166 |
if (m_tmpdir.empty() || access(m_tmpdir.c_str(), 0) < 0)
|
166 |
if (m_tmpdir.empty() || access(m_tmpdir.c_str(), 0) < 0)
|
167 |
if (!maketmpdir(m_tmpdir)) {
|
167 |
if (!maketmpdir(m_tmpdir)) {
|
168 |
LOGERR(("DbIndexer: cannot create temporary directory\n"));
|
168 |
LOGERR(("DbIndexer: cannot create temporary directory\n"));
|
169 |
return false;
|
169 |
return false;
|
170 |
}
|
170 |
}
|
171 |
if (!m_db.open(m_dbdir, resetbefore ? Rcl::Db::DbTrunc : Rcl::Db::DbUpd)) {
|
171 |
Rcl::Db::OpenMode mode = rdonly ? Rcl::Db::DbRO :
|
|
|
172 |
resetbefore ? Rcl::Db::DbTrunc : Rcl::Db::DbUpd;
|
|
|
173 |
if (!m_db.open(m_dbdir, mode)) {
|
172 |
LOGERR(("DbIndexer: error opening database in %s\n", m_dbdir.c_str()));
|
174 |
LOGERR(("DbIndexer: error opening database in %s\n", m_dbdir.c_str()));
|
173 |
return false;
|
175 |
return false;
|
174 |
}
|
176 |
}
|
175 |
return true;
|
177 |
return true;
|
176 |
}
|
178 |
}
|
177 |
|
179 |
|
178 |
bool DbIndexer::createStemDb(const string &lang)
|
180 |
bool DbIndexer::createStemDb(const string &lang)
|
179 |
{
|
181 |
{
|
180 |
if (!init())
|
182 |
if (!init(false, true))
|
181 |
return false;
|
183 |
return false;
|
182 |
return m_db.createStemDb(lang);
|
184 |
return m_db.createStemDb(lang);
|
183 |
}
|
185 |
}
|
184 |
|
186 |
|
185 |
// The language for the aspell dictionary is handled internally by the aspell
|
187 |
// The language for the aspell dictionary is handled internally by the aspell
|
186 |
// module, either from a configuration variable or the NLS environment.
|
188 |
// module, either from a configuration variable or the NLS environment.
|
187 |
bool DbIndexer::createAspellDict()
|
189 |
bool DbIndexer::createAspellDict()
|
188 |
{
|
190 |
{
|
189 |
LOGDEB2(("DbIndexer::createAspellDict()\n"));
|
191 |
LOGDEB2(("DbIndexer::createAspellDict()\n"));
|
190 |
#ifdef RCL_USE_ASPELL
|
192 |
#ifdef RCL_USE_ASPELL
|
|
|
193 |
bool noaspell = false;
|
|
|
194 |
m_config->getConfParam("noaspell", &noaspell);
|
|
|
195 |
if (noaspell)
|
|
|
196 |
return true;
|
|
|
197 |
|
191 |
if (!init())
|
198 |
if (!init(false, true))
|
192 |
return false;
|
199 |
return false;
|
193 |
Aspell aspell(m_config);
|
200 |
Aspell aspell(m_config);
|
194 |
string reason;
|
201 |
string reason;
|
195 |
if (!aspell.init(reason)) {
|
202 |
if (!aspell.init(reason)) {
|
196 |
LOGERR(("DbIndexer::createAspellDict: aspell init failed: %s\n",
|
203 |
LOGERR(("DbIndexer::createAspellDict: aspell init failed: %s\n",
|