aboutsummaryrefslogtreecommitdiff
path: root/notmuch-insert.c
diff options
context:
space:
mode:
authorJani Nikula <jani@nikula.org>2014-09-28 17:40:59 +0300
committerDavid Bremner <david@tethera.net>2014-10-28 19:19:30 +0100
commit19c09d870f18f549df3d9f5a3a30a20f7279b07a (patch)
tree2172a8fd4f8ef1ce02aa3bb899034e06217378f9 /notmuch-insert.c
parent50eedb48ec7b8b961d3f865d75bb03a57b062d4f (diff)
cli/insert: add post-insert hook
The post-new hook might no longer be needed or run very often if notmuch insert is being used. Therefore a post-insert hook is needed (arguably pre-insert not so much, so don't add one). Also add the --no-hooks option to skip hooks.
Diffstat (limited to 'notmuch-insert.c')
-rw-r--r--notmuch-insert.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/notmuch-insert.c b/notmuch-insert.c
index 0d2d810a..90fe3bad 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -454,6 +454,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
const char *folder = NULL;
notmuch_bool_t create_folder = FALSE;
notmuch_bool_t keep = FALSE;
+ notmuch_bool_t no_hooks = FALSE;
notmuch_bool_t synchronize_flags;
const char *maildir;
char *newpath;
@@ -464,6 +465,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
{ NOTMUCH_OPT_STRING, &folder, "folder", 0, 0 },
{ NOTMUCH_OPT_BOOLEAN, &create_folder, "create-folder", 0, 0 },
{ NOTMUCH_OPT_BOOLEAN, &keep, "keep", 0, 0 },
+ { NOTMUCH_OPT_BOOLEAN, &no_hooks, "no-hooks", 'n', 0 },
{ NOTMUCH_OPT_END, 0, 0, 0, 0 }
};
@@ -565,5 +567,10 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
}
}
+ if (! no_hooks && status == NOTMUCH_STATUS_SUCCESS) {
+ /* Ignore hook failures. */
+ notmuch_run_hook (db_path, "post-insert");
+ }
+
return status ? EXIT_FAILURE : EXIT_SUCCESS;
}