firstindexing was never run because the status file was trucated before it was tested for being not empty

This commit is contained in:
Jean-Francois Dockes 2015-08-19 13:22:30 +02:00
parent e1bb1a3022
commit 2c2f375a33
2 changed files with 14 additions and 11 deletions

View File

@ -19,8 +19,7 @@
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include "safesystat.h"
#include <unistd.h>
#include <errno.h> #include <errno.h>
#include <algorithm> #include <algorithm>
@ -62,7 +61,6 @@ bool ConfIndexer::runFirstIndexing()
if (stat(m_config->getIdxStatusFile().c_str(), &st) == 0 && if (stat(m_config->getIdxStatusFile().c_str(), &st) == 0 &&
st.st_size > 0) { st.st_size > 0) {
LOGDEB0(("ConfIndexer::runFirstIndexing: no: status file not empty\n")); LOGDEB0(("ConfIndexer::runFirstIndexing: no: status file not empty\n"));
exit(1);
return false; return false;
} }
// And only do this if the user has kept the default topdirs (~). // And only do this if the user has kept the default topdirs (~).

View File

@ -93,17 +93,21 @@ int stopindexing;
class MyUpdater : public DbIxStatusUpdater { class MyUpdater : public DbIxStatusUpdater {
public: public:
MyUpdater(const RclConfig *config) MyUpdater(const RclConfig *config)
: m_prevphase(DbIxStatus::DBIXS_NONE) : m_fd(-1), m_stfilename(config->getIdxStatusFile()),
{ 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()));
} }
virtual bool update() 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 // Update the status file. Avoid doing it too often
if (status.phase != m_prevphase || m_chron.millis() > 300) { if (status.phase != m_prevphase || m_chron.millis() > 300) {
m_prevphase = status.phase; m_prevphase = status.phase;
@ -143,6 +147,7 @@ class MyUpdater : public DbIxStatusUpdater {
private: private:
int m_fd; int m_fd;
string m_stfilename;
Chrono m_chron; Chrono m_chron;
DbIxStatus::Phase m_prevphase; DbIxStatus::Phase m_prevphase;
}; };