diff --git a/src/common/rclinit.cpp b/src/common/rclinit.cpp index 47607a24..699cfeaf 100644 --- a/src/common/rclinit.cpp +++ b/src/common/rclinit.cpp @@ -112,7 +112,6 @@ RclConfig *recollinit(RclInitFlags flags, // Init unac locking unac_init_mt(); - // Init smallut and pathut static values pathut_init_mt(); smallut_init_mt(); diff --git a/src/index/recollindex.cpp b/src/index/recollindex.cpp index 2c6cd54c..4de2740a 100644 --- a/src/index/recollindex.cpp +++ b/src/index/recollindex.cpp @@ -364,6 +364,18 @@ int main(int argc, char **argv) } 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 inPlaceReset((op_flags & OPT_Z) != 0); Pidfile pidfile(config->getPidfile()); diff --git a/src/sampleconf/recoll.conf.in b/src/sampleconf/recoll.conf.in index 7bf43552..667bfd8f 100644 --- a/src/sampleconf/recoll.conf.in +++ b/src/sampleconf/recoll.conf.in @@ -51,6 +51,15 @@ logfilename = stderr # daemloglevel = 3 # 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, # searches sensitive to case and diacritics can be performed, but the index # will be bigger, and some marginal weirdness may sometimes occur. We diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index 3ca1e411..44917de6 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -95,7 +95,7 @@ bool fsocc(const string &path, int *pc, long *blocks) return true; } -static const string& tmplocation() +const string& tmplocation() { static string stmpdir; if (stmpdir.empty()) { diff --git a/src/utils/pathut.h b/src/utils/pathut.h index 15bd10ee..2ef8ff3a 100644 --- a/src/utils/pathut.h +++ b/src/utils/pathut.h @@ -74,7 +74,10 @@ bool fsocc(const string &path, int *pc, // Percent occupied 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); /// mkdir -p