From 89375f5e8095beb4a7a4ca140d2cb3dfc6418c11 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Tue, 23 Jun 2020 09:03:07 +0200 Subject: [PATCH] If XDG_RUNTIME_DIR is set, locate index.pid in it. Thanks to Madhu for providing this fix --- src/common/rclconfig.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp index 663e9d0e..336f73c7 100644 --- a/src/common/rclconfig.cpp +++ b/src/common/rclconfig.cpp @@ -53,6 +53,7 @@ #include "fstreewalk.h" #include "cpuconf.h" #include "execmd.h" +#include "md5.h" using namespace std; @@ -1386,10 +1387,24 @@ string RclConfig::getIdxStatusFile() const { return getCachedirPath("idxstatusfile", "idxstatus.txt"); } + +// The pid file is opened r/w every second by the GUI to check if the +// indexer is running. This is a problem for systems which spin down +// their disks. Locate it in XDG_RUNTIME_DIR if this is set. +// Thanks to user Madhu for this fix. string RclConfig::getPidfile() const { + const char *p = getenv("XDG_RUNTIME_DIR"); + if (p) { + string base = path_canon(p); + string digest; + return path_cat( + base, "/recoll-" + MD5HexPrint(getConfDir(), digest) + "-index.pid"); + } return path_cat(getCacheDir(), "index.pid"); } + + string RclConfig::getIdxStopFile() const { return path_cat(getCacheDir(), "index.stop");