centralize dbdir computation in rclconfig+cat with conffdir if not absolute
This commit is contained in:
parent
220674f660
commit
47e1f82a91
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.28 2006-04-20 09:20:09 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.29 2006-04-28 07:54:38 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -272,6 +272,23 @@ string RclConfig::getMimeIconName(const string &mtype, string *path)
|
||||
return iconname;
|
||||
}
|
||||
|
||||
string RclConfig::getDbDir()
|
||||
{
|
||||
string dbdir;
|
||||
if (!getConfParam("dbdir", dbdir)) {
|
||||
LOGERR(("RclConfig::getDbDir: no db directory in configuration\n"));
|
||||
} else {
|
||||
dbdir = path_tildexpand(dbdir);
|
||||
// If not an absolute path, compute relative to config dir
|
||||
if (dbdir.at(0) != '/') {
|
||||
LOGDEB1(("Dbdir not abs, catting with confdir\n"));
|
||||
dbdir = path_cat(m_confdir, dbdir);
|
||||
}
|
||||
}
|
||||
LOGDEB1(("RclConfig::getDbDir: dbdir: [%s]\n", dbdir.c_str()));
|
||||
return dbdir;
|
||||
}
|
||||
|
||||
|
||||
// Look up an executable filter. We look in $RECOLL_FILTERSDIR,
|
||||
// filtersdir in config file, then let the system use the PATH
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _RCLCONFIG_H_INCLUDED_
|
||||
#define _RCLCONFIG_H_INCLUDED_
|
||||
/* @(#$Id: rclconfig.h,v 1.19 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: rclconfig.h,v 1.20 2006-04-28 07:54:38 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <list>
|
||||
|
||||
@ -53,12 +53,15 @@ class RclConfig {
|
||||
bool getConfParam(const std::string &name, int *value);
|
||||
/** Variant with autoconversion to bool */
|
||||
bool getConfParam(const std::string &name, bool *value);
|
||||
|
||||
/** Get default charset for current keydir (was set during setKeydir)
|
||||
* filenames are handled differently */
|
||||
const string &getDefCharset(bool filename = false);
|
||||
/** Get guessCharset for current keydir (was set during setKeydir) */
|
||||
bool getGuessCharset() {return guesscharset;}
|
||||
|
||||
/** Get database directory */
|
||||
string getDbDir();
|
||||
|
||||
/**
|
||||
* Get list of ignored suffixes from mimemap
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.32 2006-04-25 09:59:12 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.33 2006-04-28 07:54:38 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -369,13 +369,13 @@ bool ConfIndexer::index(bool resetbefore)
|
||||
}
|
||||
}
|
||||
m_config->setKeyDir(doctopdir);
|
||||
if (!m_config->getConfParam("dbdir", dbdir)) {
|
||||
dbdir = m_config->getDbDir();
|
||||
if (dbdir.empty()) {
|
||||
LOGERR(("ConfIndexer::index: no database directory in "
|
||||
"configuration for %s\n", doctopdir.c_str()));
|
||||
m_reason = "No database directory set for " + doctopdir;
|
||||
return false;
|
||||
}
|
||||
dbdir = path_tildexpand(dbdir);
|
||||
dbit = dbmap.find(dbdir);
|
||||
if (dbit == dbmap.end()) {
|
||||
list<string> l;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.18 2006-04-18 08:53:27 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.19 2006-04-28 07:54:38 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -48,14 +48,12 @@ static bool indexfiles(RclConfig *config, const list<string> &filenames)
|
||||
// Note that we do not bother to check for multiple databases,
|
||||
// which are currently a fiction anyway.
|
||||
config->setKeyDir(path_getfather(*filenames.begin()));
|
||||
string dbdir;
|
||||
if (!config->getConfParam("dbdir", dbdir)) {
|
||||
string dbdir = config->getDbDir();
|
||||
if (dbdir.empty()) {
|
||||
LOGERR(("indexfiles: no database directory in "
|
||||
"configuration for %s\n", filenames.begin()->c_str()));
|
||||
return false;
|
||||
}
|
||||
dbdir = path_tildexpand(dbdir);
|
||||
|
||||
dbindexer = new DbIndexer(config, dbdir);
|
||||
return dbindexer->indexFiles(filenames);
|
||||
}
|
||||
@ -65,12 +63,11 @@ static bool createstemdb(RclConfig *config, const string &lang)
|
||||
{
|
||||
// Note that we do not bother to check for multiple databases,
|
||||
// which are currently a fiction anyway.
|
||||
string dbdir;
|
||||
if (!config->getConfParam("dbdir", dbdir)) {
|
||||
string dbdir = config->getDbDir();
|
||||
if (dbdir.empty()) {
|
||||
LOGERR(("createstemdb: no database directory in configuration\n"));
|
||||
return false;
|
||||
}
|
||||
dbdir = path_tildexpand(dbdir);
|
||||
dbindexer = new DbIndexer(config, dbdir);
|
||||
return dbindexer->createStemDb(lang);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: kio_recoll.cpp,v 1.3 2006-01-19 14:57:59 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: kio_recoll.cpp,v 1.4 2006-04-28 07:54:38 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@ -38,14 +38,14 @@ RecollProtocol::RecollProtocol(const QCString &pool, const QCString &app)
|
||||
m_reason = string("Configuration problem: ") + reason;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_rclconfig->getConfParam(string("dbdir"), m_dbdir) == 0) {
|
||||
m_dbdir = m_rclconfig->getDbDir();
|
||||
if (m_dbdir.empty()) {
|
||||
// Note: this will have to be replaced by a call to a
|
||||
// configuration buildin dialog for initial configuration
|
||||
m_reason = "No db directory in configuration ??";
|
||||
return;
|
||||
}
|
||||
m_dbdir = path_tildexpand(m_dbdir);
|
||||
|
||||
m_rcldb = new Rcl::Db;
|
||||
if (!m_rcldb) {
|
||||
m_reason = "Could not build database object. (out of memory ?)";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.43 2006-04-22 06:27:37 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.44 2006-04-28 07:54:38 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -195,8 +195,8 @@ int main( int argc, char ** argv )
|
||||
|
||||
|
||||
mainWindow->sSearch->searchTypCMB->setCurrentItem(prefs.ssearchTyp);
|
||||
|
||||
if (rclconfig->getConfParam(string("dbdir"), dbdir) == 0) {
|
||||
dbdir = rclconfig->getDbDir();
|
||||
if (dbdir.empty()) {
|
||||
// Note: this will have to be replaced by a call to a
|
||||
// configuration buildin dialog for initial configuration
|
||||
QMessageBox::critical(0, "Recoll",
|
||||
@ -204,7 +204,6 @@ int main( int argc, char ** argv )
|
||||
"No db directory in configuration"));
|
||||
exit(1);
|
||||
}
|
||||
dbdir = path_tildexpand(dbdir);
|
||||
|
||||
rcldb = new Rcl::Db;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: qtry.cpp,v 1.7 2006-01-23 13:32:28 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: qtry.cpp,v 1.8 2006-04-28 07:54:38 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -86,12 +86,12 @@ int main(int argc, char **argv)
|
||||
if (!rclconfig->ok())
|
||||
cerr << "Config could not be built" << endl;
|
||||
|
||||
string dbdir;
|
||||
if (rclconfig->getConfParam(string("dbdir"), dbdir) == 0) {
|
||||
string dbdir = rclconfig->getDbDir();
|
||||
if (dbdir.empty()) {
|
||||
cerr << "No database directory in configuration" << endl;
|
||||
exit(1);
|
||||
}
|
||||
dbdir = path_tildexpand(dbdir);
|
||||
|
||||
Rcl::Db *rcldb = new Rcl::Db;
|
||||
|
||||
if (!rcldb->open(dbdir, Rcl::Db::DbRO)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user