summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2021-08-12 17:56:00 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2021-08-12 17:56:00 +0300
commitb465c1f779f6546561bbefc09404957047dd6fa5 (patch)
tree3b67dd0cb8917bc767deafbdadab3b239eb511e2
parent6537de11162cfea543cf8820546780aca9a5df9a (diff)
index: make lazy check less lazy
We got many reports where the 'lazy check' didn't work too well for people... so make it a bit less lazy, so it'll just work for more people. In practice, never skip _directories_ unless they're leaf directories; this avoids the mtime-does-not-bubble-up problem.
-rw-r--r--lib/index/mu-indexer.cc10
-rw-r--r--lib/index/mu-scanner.cc13
-rw-r--r--lib/index/mu-scanner.hh7
3 files changed, 20 insertions, 10 deletions
diff --git a/lib/index/mu-indexer.cc b/lib/index/mu-indexer.cc
index 8a44e51..9a43316 100644
--- a/lib/index/mu-indexer.cc
+++ b/lib/index/mu-indexer.cc
@@ -115,12 +115,16 @@ Indexer::Private::handler (const std::string& fullpath, struct stat *statbuf,
Scanner::HandleType htype)
{
switch (htype) {
- case Scanner::HandleType::EnterDir: {
+ case Scanner::HandleType::EnterDir:
+ case Scanner::HandleType::EnterNewCur: {
// in lazy-mode, we ignore this dir if its dirstamp suggest it
// is up-to-date (this is _not_ always true; hence we call it
- // lazy-mode)
+ // 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_mtime) {
+ if (conf_.lazy_check &&
+ dirstamp_ == statbuf->st_mtime &&
+ htype == Scanner::HandleType::EnterNewCur) {
g_debug("skip %s (seems up-to-date)", fullpath.c_str());
return false;
}
diff --git a/lib/index/mu-scanner.cc b/lib/index/mu-scanner.cc
index 65746ea..dc714c9 100644
--- a/lib/index/mu-scanner.cc
+++ b/lib/index/mu-scanner.cc
@@ -96,14 +96,15 @@ Scanner::Private::process_dentry (const std::string& path, struct dirent *dentry
}
if (S_ISDIR(statbuf.st_mode)) {
-
- const auto res = handler_(fullpath, &statbuf, Scanner::HandleType::EnterDir);
- if (!res) {
- //g_debug ("skipping dir %s", fullpath.c_str());
+ const auto new_cur = is_new_cur(dentry->d_name);
+ const auto htype = new_cur ?
+ Scanner::HandleType::EnterNewCur :
+ Scanner::HandleType::EnterDir;
+ const auto res = handler_(fullpath, &statbuf, htype);
+ if (!res)
return true; // skip
- }
- process_dir (fullpath, is_new_cur(dentry->d_name));
+ process_dir (fullpath, new_cur);
return handler_(fullpath, &statbuf, Scanner::HandleType::LeaveDir);
diff --git a/lib/index/mu-scanner.hh b/lib/index/mu-scanner.hh
index 3dc1fcc..1b0d6c4 100644
--- a/lib/index/mu-scanner.hh
+++ b/lib/index/mu-scanner.hh
@@ -42,7 +42,12 @@ namespace Mu {
///
class Scanner {
public:
- enum struct HandleType { File, EnterDir, LeaveDir };
+ enum struct HandleType {
+ File,
+ EnterNewCur, /* cur/ or new/ */
+ EnterDir, /* some other directory */
+ LeaveDir
+ };
/// Prototype for a handler function
using Handler = std::function<bool(const std::string& fullpath,