--- a/src/utils/pathut.cpp
+++ b/src/utils/pathut.cpp
@@ -95,14 +95,18 @@
return true;
}
-static const char *tmplocation()
-{
- const char *tmpdir = getenv("RECOLL_TMPDIR");
- if (!tmpdir)
- tmpdir = getenv("TMPDIR");
- if (!tmpdir)
- tmpdir = "/tmp";
- return tmpdir;
+static const string& tmplocation()
+{
+ static string stmpdir;
+ if (stmpdir.empty()) {
+ const char *tmpdir = getenv("RECOLL_TMPDIR");
+ if (tmpdir == 0)
+ tmpdir = getenv("TMPDIR");
+ if (tmpdir == 0)
+ tmpdir = "/tmp";
+ stmpdir = string(tmpdir);
+ }
+ return stmpdir;
}
bool maketmpdir(string& tdir, string& reason)