mu: add '--lazy-check' option for indexing
Add an option --lazy-check to ignore any directories that don't have their ctime changed since the last indexing operation. There are a few corner-cases (such as editing a message outside mu's control) where this might miss a change, but apart from that, makes indexing in for a maildir (and its sub-maildirs) almost a no-op if there were no changes.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||
|
||||
/*
|
||||
** Copyright (C) 2008-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
** Copyright (C) 2008-2016 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the GNU General Public License as published by the
|
||||
@ -49,24 +49,24 @@ sig_handler (int sig)
|
||||
"press again to kill immediately");
|
||||
}
|
||||
|
||||
MU_CAUGHT_SIGNAL = TRUE;
|
||||
MU_CAUGHT_SIGNAL = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
install_sig_handler (void)
|
||||
{
|
||||
struct sigaction action;
|
||||
int i, sigs[] = { SIGINT, SIGHUP, SIGTERM };
|
||||
struct sigaction action;
|
||||
int i, sigs[] = { SIGINT, SIGHUP, SIGTERM };
|
||||
|
||||
MU_CAUGHT_SIGNAL = FALSE;
|
||||
MU_CAUGHT_SIGNAL = FALSE;
|
||||
|
||||
action.sa_handler = sig_handler;
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_flags = SA_RESETHAND;
|
||||
action.sa_handler = sig_handler;
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_flags = SA_RESETHAND;
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(sigs); ++i)
|
||||
if (sigaction (sigs[i], &action, NULL) != 0)
|
||||
g_critical ("set sigaction for %d failed: %s",
|
||||
for (i = 0; i != G_N_ELEMENTS(sigs); ++i)
|
||||
if (sigaction (sigs[i], &action, NULL) != 0)
|
||||
g_critical ("set sigaction for %d failed: %s",
|
||||
sigs[i], strerror (errno));;
|
||||
}
|
||||
|
||||
@ -319,7 +319,8 @@ cmd_index (MuIndex *midx, MuConfig *opts, MuIndexStats *stats, GError **err)
|
||||
|
||||
newline_before_on();
|
||||
|
||||
rv = mu_index_run (midx, opts->maildir, opts->rebuild, stats,
|
||||
rv = mu_index_run (midx, opts->maildir, opts->rebuild,
|
||||
opts->lazycheck, stats,
|
||||
show_progress ?
|
||||
(MuIndexMsgCallback)index_msg_cb :
|
||||
(MuIndexMsgCallback)index_msg_silent_cb,
|
||||
|
||||
@ -148,6 +148,8 @@ config_options_group_index (void)
|
||||
"top of the maildir", "<maildir>"},
|
||||
{"rebuild", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.rebuild,
|
||||
"rebuild the database from scratch (false)", NULL},
|
||||
{"lazy-check", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.lazycheck,
|
||||
"only check dir-timestamps (false)", NULL},
|
||||
{"my-address", 0, 0, G_OPTION_ARG_STRING_ARRAY,
|
||||
&MU_CONFIG.my_addresses,
|
||||
"my e-mail address (regexp); can be used multiple times",
|
||||
@ -307,7 +309,7 @@ config_options_group_script (void)
|
||||
GOptionEntry entries[] = {
|
||||
{G_OPTION_REMAINING, 0,0, G_OPTION_ARG_STRING_ARRAY,
|
||||
&MU_CONFIG.params, "script parameters", NULL},
|
||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
og = g_option_group_new("script", "Options for the 'script' command",
|
||||
|
||||
@ -112,6 +112,8 @@ struct _MuConfig {
|
||||
gboolean rebuild; /* empty the database before indexing */
|
||||
gboolean autoupgrade; /* automatically upgrade db
|
||||
* when needed */
|
||||
gboolean lazycheck; /* don't check dirs with up-to-date
|
||||
* timestamps */
|
||||
int xbatchsize; /* batchsize for xapian
|
||||
* commits, or 0 for
|
||||
* default */
|
||||
|
||||
Reference in New Issue
Block a user