Add parameter to chdir on recollindex startup, /tmp by default. Closes issue #129

This commit is contained in:
Jean-Francois Dockes 2013-03-07 11:05:54 +01:00
parent 2c06368d99
commit cebaed48aa
5 changed files with 26 additions and 3 deletions

View file

@ -112,7 +112,6 @@ RclConfig *recollinit(RclInitFlags flags,
// Init unac locking // Init unac locking
unac_init_mt(); unac_init_mt();
// Init smallut and pathut static values // Init smallut and pathut static values
pathut_init_mt(); pathut_init_mt();
smallut_init_mt(); smallut_init_mt();

View file

@ -364,6 +364,18 @@ int main(int argc, char **argv)
} }
o_reexec->atexit(cleanup); o_reexec->atexit(cleanup);
string rundir;
config->getConfParam("idxrundir", rundir);
if (!rundir.compare("tmp")) {
LOGDEB(("recollindex: changing current directory to [%s]\n",
tmplocation().c_str()));
chdir(tmplocation().c_str());
} else if (!rundir.empty()) {
LOGDEB(("recollindex: changing current directory to [%s]\n",
rundir.c_str()));
chdir(rundir.c_str());
}
bool rezero((op_flags & OPT_z) != 0); bool rezero((op_flags & OPT_z) != 0);
bool inPlaceReset((op_flags & OPT_Z) != 0); bool inPlaceReset((op_flags & OPT_Z) != 0);
Pidfile pidfile(config->getPidfile()); Pidfile pidfile(config->getPidfile());

View file

@ -51,6 +51,15 @@ logfilename = stderr
# daemloglevel = 3 # daemloglevel = 3
# daemlogfilename = /dev/null # daemlogfilename = /dev/null
# Run directory for the indexing process. The filters sometimes leave
# garbage in the current directory, so it makes sense to have recollindex
# chdir to some garbage bin. 3 possible values:
# - (literal) tmp : go to temp dir as set by env (RECOLL_TMPDIR else
# TMPDIR else /tmp)
# - Empty: stay were started
# - Absolute path value: go there.
idxrundir = tmp
# Decide if we store character case and diacritics in the index. If we do, # Decide if we store character case and diacritics in the index. If we do,
# searches sensitive to case and diacritics can be performed, but the index # searches sensitive to case and diacritics can be performed, but the index
# will be bigger, and some marginal weirdness may sometimes occur. We # will be bigger, and some marginal weirdness may sometimes occur. We

View file

@ -95,7 +95,7 @@ bool fsocc(const string &path, int *pc, long *blocks)
return true; return true;
} }
static const string& tmplocation() const string& tmplocation()
{ {
static string stmpdir; static string stmpdir;
if (stmpdir.empty()) { if (stmpdir.empty()) {

View file

@ -74,7 +74,10 @@ bool fsocc(const string &path, int *pc, // Percent occupied
long *avmbs = 0 // Mbs available to non-superuser long *avmbs = 0 // Mbs available to non-superuser
); );
/// Create temporary directory /// Retrieve the temp dir location: $RECOLL_TMPDIR else $TMPDIR else /tmp
extern const string& tmplocation();
/// Create temporary directory (inside the temp location)
extern bool maketmpdir(string& tdir, string& reason); extern bool maketmpdir(string& tdir, string& reason);
/// mkdir -p /// mkdir -p