[PATCH 1/2] CLI/new: add mtime-opt option
David Bremner
david at tethera.net
Sun Apr 29 04:48:57 PDT 2018
This option, on by default, controls whether mtimes are used to
optimize the scanning of directories. The intent is to turn this
optimization off for certain tests.
---
notmuch-new.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/notmuch-new.c b/notmuch-new.c
index c4345705..099bbbae 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -47,6 +47,7 @@ typedef struct {
int output_is_a_tty;
enum verbosity verbosity;
bool debug;
+ bool mtime_opt;
const char **new_tags;
size_t new_tags_length;
const char **ignore_verbatim;
@@ -527,7 +528,7 @@ add_files (notmuch_database_t *notmuch,
* mistakenly return the total number of directory entries, since
* that only inflates the count beyond 2.
*/
- if (directory && fs_mtime == db_mtime && st.st_nlink == 2) {
+ if (directory && state->mtime_opt && fs_mtime == db_mtime && st.st_nlink == 2) {
/* There's one catch: pass 1 below considers symlinks to
* directories to be directories, but these don't increase the
* file system link count. So, only bail early if the
@@ -618,7 +619,7 @@ add_files (notmuch_database_t *notmuch,
* being discovered until the clock catches up and the directory
* is modified again).
*/
- if (directory && fs_mtime == db_mtime)
+ if (directory && state->mtime_opt && fs_mtime == db_mtime)
goto DONE;
/* If the database has never seen this directory before, we can
@@ -771,7 +772,7 @@ add_files (notmuch_database_t *notmuch,
* the database because a message could be delivered later in this
* same second. This may lead to unnecessary re-scans, but it
* avoids overlooking messages. */
- if (fs_mtime != stat_time)
+ if (state->mtime_opt && fs_mtime != stat_time)
_filename_list_add (state->directory_mtimes, path)->mtime = fs_mtime;
DONE:
@@ -1053,6 +1054,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
add_files_state_t add_files_state = {
.verbosity = VERBOSITY_NORMAL,
.debug = false,
+ .mtime_opt = true,
.output_is_a_tty = isatty (fileno (stdout)),
};
struct timeval tv_start;
@@ -1073,6 +1075,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
{ .opt_bool = &quiet, .name = "quiet" },
{ .opt_bool = &verbose, .name = "verbose" },
{ .opt_bool = &add_files_state.debug, .name = "debug" },
+ { .opt_bool = &add_files_state.mtime_opt, .name = "mtime-opt" },
{ .opt_bool = &hooks, .name = "hooks" },
{ .opt_inherit = notmuch_shared_indexing_options },
{ .opt_inherit = notmuch_shared_options },
--
2.17.0
More information about the notmuch
mailing list