Windows: only retry failed files if exec is newer than dbdir
This commit is contained in:
parent
be57d0153a
commit
a67ce0a1e8
@ -16,25 +16,51 @@
|
||||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include "checkretryfailed.h"
|
||||
|
||||
#include "safesysstat.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "rclconfig.h"
|
||||
#include "execmd.h"
|
||||
#include "log.h"
|
||||
#include "checkretryfailed.h"
|
||||
#include "pathut.h"
|
||||
#include "recollindex.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool checkRetryFailed(RclConfig *conf, bool record)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return true;
|
||||
// Under Windows we only retry if the recollindex program is newer
|
||||
// than the index
|
||||
struct stat st;
|
||||
string path(thisprog);
|
||||
if (path_suffix(path).empty()) {
|
||||
path = path + ".exe";
|
||||
}
|
||||
if (path_fileprops(path, &st) != 0) {
|
||||
LOGERR("checkRetryFailed: can't stat the program file: " <<
|
||||
thisprog << endl);
|
||||
return false;
|
||||
}
|
||||
time_t exetime = st.st_mtime;
|
||||
if (path_fileprops(conf->getDbDir(), &st) != 0) {
|
||||
// Maybe it just does not exist.
|
||||
LOGDEB("checkRetryFailed: can't stat the index directory: " <<
|
||||
conf->getDbDir() << endl);
|
||||
return false;
|
||||
}
|
||||
time_t dbtime = st.st_mtime;
|
||||
return exetime > dbtime;
|
||||
#else
|
||||
string cmd;
|
||||
|
||||
if (!conf->getConfParam("checkneedretryindexscript", cmd)) {
|
||||
LOGDEB("checkRetryFailed: 'checkneedretryindexscript' not set in config\n" );
|
||||
LOGDEB("checkRetryFailed: 'checkneedretryindexscript' "
|
||||
"not set in config\n");
|
||||
// We could toss a dice ? Say no retry in this case.
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -427,7 +427,7 @@ bool runWebFilesMoverScript(RclConfig *config)
|
||||
}
|
||||
|
||||
|
||||
static const char *thisprog;
|
||||
string thisprog;
|
||||
|
||||
static const char usage [] =
|
||||
"\n"
|
||||
@ -483,7 +483,7 @@ static void
|
||||
Usage(FILE *where = stderr)
|
||||
{
|
||||
FILE *fp = (op_flags & OPT_h) ? stdout : stderr;
|
||||
fprintf(fp, "%s: Usage: %s", thisprog, usage);
|
||||
fprintf(fp, "%s: Usage: %s", path_getsimple(thisprog).c_str(), usage);
|
||||
fprintf(fp, "Recoll version: %s\n", Rcl::version_string().c_str());
|
||||
exit((op_flags & OPT_h)==0);
|
||||
}
|
||||
@ -565,7 +565,7 @@ int main(int argc, char **argv)
|
||||
o_reexec->init(argc, argv);
|
||||
#endif
|
||||
|
||||
thisprog = argv[0];
|
||||
thisprog = path_absolute(argv[0]);
|
||||
argc--; argv++;
|
||||
|
||||
while (argc > 0 && **argv == '-') {
|
||||
@ -697,7 +697,10 @@ int main(int argc, char **argv)
|
||||
indexerFlags &= ~ConfIndexer::IxFNoRetryFailed;
|
||||
} else {
|
||||
if (checkRetryFailed(config, false)) {
|
||||
LOGDEB("recollindex: files in error will be retried\n");
|
||||
indexerFlags &= ~ConfIndexer::IxFNoRetryFailed;
|
||||
} else {
|
||||
LOGDEB("recollindex: files in error will not be retried\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -43,5 +43,6 @@ extern void addIdxReason(std::string who, std::string reason);
|
||||
|
||||
class ReExec;
|
||||
extern ReExec *o_reexec;
|
||||
extern std::string thisprog;
|
||||
|
||||
#endif /* _recollindex_h_included_ */
|
||||
|
||||
@ -39,7 +39,6 @@ SOURCES += \
|
||||
../../common/utf8fn.cpp \
|
||||
../../index/webqueue.cpp \
|
||||
../../index/webqueuefetcher.cpp \
|
||||
../../index/checkretryfailed.cpp \
|
||||
../../index/fetcher.cpp \
|
||||
../../index/exefetcher.cpp \
|
||||
../../index/fsfetcher.cpp \
|
||||
|
||||
@ -15,6 +15,7 @@ DEFINES += RCL_MONITOR
|
||||
|
||||
SOURCES += \
|
||||
../../index/recollindex.cpp \
|
||||
../../index/checkretryfailed.cpp \
|
||||
../../index/rclmonprc.cpp \
|
||||
../../index/rclmonrcv.cpp
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user