Add cachedir variable allowing to move all data directories by setting a single value. Closes issue #270
This commit is contained in:
parent
b995cfb4e8
commit
f3820471e4
@ -220,17 +220,7 @@ bool Aspell::ok() const
|
||||
|
||||
string Aspell::dicPath()
|
||||
{
|
||||
string ccdir;
|
||||
m_config->getConfParam("aspellDicDir", ccdir);
|
||||
if (ccdir.empty()) {
|
||||
ccdir = m_config->getConfDir();
|
||||
} else {
|
||||
ccdir = path_tildexpand(ccdir);
|
||||
// If not an absolute path, compute relative to config dir
|
||||
if (!path_isabsolute(ccdir))
|
||||
ccdir = path_cat(m_config->getConfDir(), ccdir);
|
||||
}
|
||||
|
||||
string ccdir = m_config->getAspellcacheDir();
|
||||
return path_cat(ccdir, string("aspdict.") + m_lang + string(".rws"));
|
||||
}
|
||||
|
||||
|
||||
@ -29,14 +29,7 @@ const string cstr_bgc_mimetype("mimetype");
|
||||
|
||||
BeagleQueueCache::BeagleQueueCache(RclConfig *cnf)
|
||||
{
|
||||
string ccdir;
|
||||
cnf->getConfParam("webcachedir", ccdir);
|
||||
if (ccdir.empty())
|
||||
ccdir = "webcache";
|
||||
ccdir = path_tildexpand(ccdir);
|
||||
// If not an absolute path, compute relative to config dir
|
||||
if (!path_isabsolute(ccdir))
|
||||
ccdir = path_cat(cnf->getConfDir(), ccdir);
|
||||
string ccdir = cnf->getWebcacheDir();
|
||||
|
||||
int maxmbs = 40;
|
||||
cnf->getConfParam("webcachemaxmbs", &maxmbs);
|
||||
|
||||
@ -337,6 +337,9 @@ bool RclConfig::updateMainConfig()
|
||||
m_index_stripchars_init = 1;
|
||||
}
|
||||
|
||||
if (getConfParam("cachedir", m_cachedir)) {
|
||||
m_cachedir = path_canon(path_tildexpand(m_cachedir));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -810,7 +813,7 @@ bool RclConfig::getMissingHelperDesc(string& out) const
|
||||
|
||||
void RclConfig::storeMissingHelperDesc(const string &s)
|
||||
{
|
||||
string fmiss = path_cat(getConfDir(), "missing");
|
||||
string fmiss = path_cat(getCacheDir(), "missing");
|
||||
FILE *fp = fopen(fmiss.c_str(), "w");
|
||||
if (fp) {
|
||||
if (s.size() > 0 && fwrite(s.c_str(), s.size(), 1, fp) != 1) {
|
||||
@ -1147,9 +1150,43 @@ string RclConfig::getConfdirPath(const char *varname, const char *dflt) const
|
||||
|
||||
}
|
||||
|
||||
string RclConfig::getCacheDir() const
|
||||
{
|
||||
return m_cachedir.empty() ? getConfDir() : m_cachedir;
|
||||
}
|
||||
|
||||
// Return path defined by varname. May be absolute or relative to
|
||||
// confdir, with default in confdir
|
||||
string RclConfig::getCachedirPath(const char *varname, const char *dflt) const
|
||||
{
|
||||
string result;
|
||||
if (!getConfParam(varname, result)) {
|
||||
result = path_cat(getCacheDir(), dflt);
|
||||
} else {
|
||||
result = path_tildexpand(result);
|
||||
// If not an absolute path, compute relative to cache dir
|
||||
if (!path_isabsolute(result)) {
|
||||
result = path_cat(getCacheDir(), result);
|
||||
}
|
||||
}
|
||||
return path_canon(result);
|
||||
}
|
||||
|
||||
string RclConfig::getDbDir() const
|
||||
{
|
||||
return getConfdirPath("dbdir", "xapiandb");
|
||||
return getCachedirPath("dbdir", "xapiandb");
|
||||
}
|
||||
string RclConfig::getWebcacheDir() const
|
||||
{
|
||||
return getCachedirPath("webcachedir", "webcache");
|
||||
}
|
||||
string RclConfig::getMboxcacheDir() const
|
||||
{
|
||||
return getCachedirPath("mboxcachedir", "mboxcache");
|
||||
}
|
||||
string RclConfig::getAspellcacheDir() const
|
||||
{
|
||||
return getCachedirPath("aspellDicDir", "");
|
||||
}
|
||||
|
||||
string RclConfig::getStopfile() const
|
||||
@ -1164,9 +1201,14 @@ string RclConfig::getSynGroupsFile() const
|
||||
|
||||
// The index status file is fast changing, so it's possible to put it outside
|
||||
// of the config directory (for ssds, not sure this is really useful).
|
||||
// To enable being quite xdg-correct we should add a getRundirPath()
|
||||
string RclConfig::getIdxStatusFile() const
|
||||
{
|
||||
return getConfdirPath("idxstatusfile", "idxstatus.txt");
|
||||
return getCachedirPath("idxstatusfile", "idxstatus.txt");
|
||||
}
|
||||
string RclConfig::getPidfile() const
|
||||
{
|
||||
return path_cat(getCacheDir(), "index.pid");
|
||||
}
|
||||
|
||||
void RclConfig::urlrewrite(const string& dbdir, string& url) const
|
||||
@ -1221,11 +1263,6 @@ bool RclConfig::sourceChanged() const
|
||||
return false;
|
||||
}
|
||||
|
||||
string RclConfig::getPidfile() const
|
||||
{
|
||||
return path_cat(getConfDir(), "index.pid");
|
||||
}
|
||||
|
||||
string RclConfig::getWebQueueDir() const
|
||||
{
|
||||
string webqueuedir;
|
||||
@ -1253,6 +1290,9 @@ vector<string> RclConfig::getSkippedPaths() const
|
||||
// don't do this.
|
||||
skpl.push_back(getDbDir());
|
||||
skpl.push_back(getConfDir());
|
||||
if (getCacheDir().compare(getConfDir())) {
|
||||
skpl.push_back(getCacheDir());
|
||||
}
|
||||
// And the web queue dir
|
||||
skpl.push_back(getWebQueueDir());
|
||||
for (vector<string>::iterator it = skpl.begin(); it != skpl.end(); it++) {
|
||||
@ -1457,6 +1497,7 @@ void RclConfig::initFrom(const RclConfig& r)
|
||||
return;
|
||||
m_reason = r.m_reason;
|
||||
m_confdir = r.m_confdir;
|
||||
m_cachedir = r.m_cachedir;
|
||||
m_datadir = r.m_datadir;
|
||||
m_keydir = r.m_keydir;
|
||||
m_cdirs = r.m_cdirs;
|
||||
|
||||
@ -109,6 +109,7 @@ class RclConfig {
|
||||
* constructor it it is the default one (~/.recoll) and it did
|
||||
* not exist yet. */
|
||||
string getConfDir() const {return m_confdir;}
|
||||
string getCacheDir() const;
|
||||
|
||||
/** Check if the config files were modified since we read them */
|
||||
bool sourceChanged() const;
|
||||
@ -172,8 +173,12 @@ class RclConfig {
|
||||
vector<string> getTopdirs() const;
|
||||
|
||||
string getConfdirPath(const char *varname, const char *dflt) const;
|
||||
/** Get database directory */
|
||||
string getCachedirPath(const char *varname, const char *dflt) const;
|
||||
/** Get database and other directories */
|
||||
string getDbDir() const;
|
||||
string getWebcacheDir() const;
|
||||
string getMboxcacheDir() const;
|
||||
string getAspellcacheDir() const;
|
||||
/** Get stoplist file name */
|
||||
string getStopfile() const;
|
||||
/** Get synonym groups file name */
|
||||
@ -333,6 +338,11 @@ class RclConfig {
|
||||
int m_ok;
|
||||
string m_reason; // Explanation for bad state
|
||||
string m_confdir; // User directory where the customized files are stored
|
||||
// Normally same as confdir. Set to store all bulk data elsewhere.
|
||||
// Provides defaults top location for dbdir, webcachedir,
|
||||
// mboxcachedir, aspellDictDir, which can still be used to
|
||||
// override.
|
||||
string m_cachedir;
|
||||
string m_datadir; // Example: /usr/local/share/recoll
|
||||
string m_keydir; // Current directory used for parameter fetches.
|
||||
int m_keydirgen; // To help with knowing when to update computed data.
|
||||
|
||||
@ -5982,7 +5982,31 @@ field2 = value for field2
|
||||
<sect3 id="RCL.INSTALL.CONFIG.RECOLLCONF.STORAGE">
|
||||
<title>Parameters affecting where and how we store things:</title>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry><term><varname>cachedir</varname></term>
|
||||
<listitem>
|
||||
<para>When not explicitly specified, the &RCL; data directories
|
||||
are stored relative to the configuration directory. If
|
||||
<literal>cachedir</literal> is set, the directories are stored
|
||||
under the specified value instead (e.g. if
|
||||
<literal>cachedir</literal> is set to
|
||||
<filename>~/.cache/recoll</filename>, the default
|
||||
<literal>dbdir</literal> would be
|
||||
<filename>~/.cache/recoll/xapiandb</filename> instead of
|
||||
<filename>~/.recoll/xapiandb</filename> ). This affects the
|
||||
default values for <literal>dbdir</literal>,
|
||||
<literal>webcachedir</literal>,
|
||||
<literal>mboxcachedir</literal>, and
|
||||
<literal>aspellDicDir</literal>, which can still be
|
||||
individually specified to override
|
||||
<literal>cachedir</literal>. Note that if you have multiple
|
||||
configurations, each must have a different
|
||||
<literal>cachedir</literal>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry><term><varname>dbdir</varname></term>
|
||||
<listitem><para>The name of the Xapian data directory. It
|
||||
will be created if needed when the index is
|
||||
|
||||
@ -196,13 +196,7 @@ public:
|
||||
}
|
||||
m_minfsize = minmbs * 1000 * 1000;
|
||||
|
||||
config->getConfParam("mboxcachedir", m_dir);
|
||||
if (m_dir.empty())
|
||||
m_dir = "mboxcache";
|
||||
m_dir = path_tildexpand(m_dir);
|
||||
// If not an absolute path, compute relative to config dir
|
||||
if (!path_isabsolute(m_dir))
|
||||
m_dir = path_cat(config->getConfDir(), m_dir);
|
||||
m_dir = config->getMboxcacheDir();
|
||||
m_ok = true;
|
||||
}
|
||||
return m_ok;
|
||||
|
||||
@ -153,10 +153,21 @@ maxTermExpand = 10000
|
||||
# eating all the memory. Default 50000
|
||||
maxXapianClauses = 50000
|
||||
|
||||
# Recoll data directories are normally stored relative to the configuration
|
||||
# directory (e.g. ~/.recoll/xapiandb, ~/.recoll/mboxcache). If this is set,
|
||||
# the directories are stored under the specified value instead
|
||||
# (e.g. if cachedir is ~/.cache/recoll, the default dbdir would be
|
||||
# ~/.cache/recoll/xapiandb).
|
||||
# This affects dbdir, webcachedir, mboxcachedir, aspellDicDir, which can
|
||||
# still be individually specified to override cachedir.
|
||||
# Note that if you have multiple configurations, each must have a different
|
||||
# cachedir, there is no automatic computation of a subpath under cachedir.
|
||||
#cachedir = ~/.cache/recoll
|
||||
|
||||
# Where to store the database (directory). This may be an absolute path,
|
||||
# else it is taken as relative to the configuration directory (-c argument
|
||||
# or $RECOLL_CONFDIR).
|
||||
# If nothing is specified, the default is then ~/.recoll/xapiandb/
|
||||
# else it is taken as relative to cachedir if set, or the configuration
|
||||
# directory (-c argument or $RECOLL_CONFDIR). If nothing is specified, the
|
||||
# default is then ~/.recoll/xapiandb/
|
||||
dbdir = xapiandb
|
||||
|
||||
# Indexing process threads configuration. If Recoll is configured for
|
||||
@ -289,6 +300,11 @@ filtermaxmbytes = 2000
|
||||
# Jessie). See Debian bug 772415
|
||||
# aspellAddCreateParam = --local-data-dir=/usr/lib/aspell
|
||||
|
||||
# The aspell dictionary (aspdict.(lang).rws) is normally stored in the
|
||||
# directory specified by cachedir if set, or under the configuration
|
||||
# directory. Set the following to change:
|
||||
#aspellDicDir =
|
||||
|
||||
# You may also want to set this to have a look at aspell dictionary
|
||||
# creation errors. But there are always many, so this is mostly for debugging
|
||||
# aspellKeepStderr = 1
|
||||
@ -329,7 +345,7 @@ processwebqueue = 0
|
||||
#webqueuedir = ~/.recollweb/ToIndex
|
||||
# This is only used by the web history indexing code, and
|
||||
# defines where the cache for visited pages will live. Default:
|
||||
# $RECOLL_CONFDIR/webcache
|
||||
# cachedir/webcache if cachedir is set, else $RECOLL_CONFDIR/webcache
|
||||
webcachedir = webcache
|
||||
# This is only used by the web history indexing code, and
|
||||
# defines the maximum size for the web page cache. Default: 40 MB.
|
||||
@ -337,7 +353,8 @@ webcachedir = webcache
|
||||
webcachemaxmbs = 40
|
||||
|
||||
# The directory where mbox message offsets cache files are held. This is
|
||||
# normally $RECOLL_CONFDIR/mboxcache, but it may be useful to share a
|
||||
# normally named mboxcache under cachedir if set, or else under the
|
||||
# configuration directory, but it may be useful to share a
|
||||
# directory between different configurations.
|
||||
#mboxcachedir = mboxcache
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user