diff --git a/src/index/indexer.cpp b/src/index/indexer.cpp index de706d07..ab56a77d 100644 --- a/src/index/indexer.cpp +++ b/src/index/indexer.cpp @@ -19,8 +19,7 @@ #endif #include -#include -#include +#include "safesystat.h" #include #include @@ -59,10 +58,9 @@ bool ConfIndexer::runFirstIndexing() { // Indexing status file existing and not empty ? struct stat st; - if (stat(m_config->getIdxStatusFile().c_str(), &st) == 0 && + if (stat(m_config->getIdxStatusFile().c_str(), &st) == 0 && st.st_size > 0) { LOGDEB0(("ConfIndexer::runFirstIndexing: no: status file not empty\n")); - exit(1); return false; } // And only do this if the user has kept the default topdirs (~). diff --git a/src/index/recollindex.cpp b/src/index/recollindex.cpp index 7044d103..f6e4eecf 100644 --- a/src/index/recollindex.cpp +++ b/src/index/recollindex.cpp @@ -93,17 +93,21 @@ int stopindexing; class MyUpdater : public DbIxStatusUpdater { public: MyUpdater(const RclConfig *config) - : m_prevphase(DbIxStatus::DBIXS_NONE) - { - m_fd = open(config->getIdxStatusFile().c_str(), - O_WRONLY|O_CREAT|O_TRUNC, 0600); - if (m_fd < 0) - LOGERR(("Can't open/create status file: [%s]\n", - config->getIdxStatusFile().c_str())); + : m_fd(-1), m_stfilename(config->getIdxStatusFile()), + m_prevphase(DbIxStatus::DBIXS_NONE) { } virtual bool update() { + if (m_fd < 0) { + m_fd = open(m_stfilename.c_str(), + O_WRONLY|O_CREAT|O_TRUNC, 0600); + if (m_fd < 0) { + LOGERR(("Can't open/create status file: [%s]\n", + m_stfilename.c_str())); + return stopindexing ? false : true; + } + } // Update the status file. Avoid doing it too often if (status.phase != m_prevphase || m_chron.millis() > 300) { m_prevphase = status.phase; @@ -143,6 +147,7 @@ class MyUpdater : public DbIxStatusUpdater { private: int m_fd; + string m_stfilename; Chrono m_chron; DbIxStatus::Phase m_prevphase; };