From 253b44043b51285d4adb9942f8f81685d86acf91 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sun, 6 Aug 2023 13:42:28 +0300 Subject: [PATCH] indexer: disable lazy check for "full" scan Lazy would actually do _more_ work a full scan. --- lib/index/mu-indexer.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/index/mu-indexer.cc b/lib/index/mu-indexer.cc index e7019c3a..3d438cf9 100644 --- a/lib/index/mu-indexer.cc +++ b/lib/index/mu-indexer.cc @@ -158,13 +158,16 @@ Indexer::Private::handler(const std::string& fullpath, struct stat* statbuf, // is up-to-date (this is _not_ always true; hence we call it // lazy-mode); only for actual message dirs, since the dir // tstamps may not bubble up. - dirstamp_ = store_.dirstamp(fullpath); - if (conf_.lazy_check && dirstamp_ >= statbuf->st_ctime && - htype == Scanner::HandleType::EnterNewCur) { - mu_debug("skip {} (seems up-to-date: {:%FT%T} >= {:%FT%T})", - fullpath, mu_time(dirstamp_), mu_time(statbuf->st_ctime)); - return false; - } + if (conf_.lazy_check) { + dirstamp_ = store_.dirstamp(fullpath); + if (dirstamp_ >= statbuf->st_ctime && + htype == Scanner::HandleType::EnterNewCur) { + mu_debug("skip {} (seems up-to-date: {:%FT%T} >= {:%FT%T})", + fullpath, mu_time(dirstamp_), mu_time(statbuf->st_ctime)); + return false; + } + } else + dirstamp_ = 0; // don't index dirs with '.noindex' auto noindex = ::access((fullpath + "/.noindex").c_str(), F_OK) == 0; @@ -379,6 +382,11 @@ Indexer::Private::start(const Indexer::Config& conf) } else max_workers_ = conf.max_threads; + if (store_.empty() && conf_.lazy_check) { + mu_debug("turn off lazy check since we have an empty store"); + conf_.lazy_check = false; + } + mu_debug("starting indexer with <= {} worker thread(s)", max_workers_); mu_debug("indexing: {}; clean-up: {}", conf_.scan ? "yes" : "no", conf_.cleanup ? "yes" : "no");