X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-new.c;h=bfb460013622959eaa8eca2dc6cd0a1df590a85e;hp=81a93500ced96e971df3562a3730e911f81819e1;hb=ed56fee6e5e8c114378f2d2def5395caab5d66a6;hpb=61f0a5b8ee2adf540106a09c5f83fe634da6beb3 diff --git a/notmuch-new.c b/notmuch-new.c index 81a93500..bfb46001 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -811,6 +811,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) _filename_node_t *f; int i; notmuch_bool_t timer_is_active = FALSE; + notmuch_bool_t run_hooks = TRUE; add_files_state.verbose = 0; add_files_state.output_is_a_tty = isatty (fileno (stdout)); @@ -820,6 +821,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) for (i = 0; i < argc && argv[i][0] == '-'; i++) { if (STRNCMP_LITERAL (argv[i], "--verbose") == 0) { add_files_state.verbose = 1; + } else if (strcmp (argv[i], "--no-hooks") == 0) { + run_hooks = FALSE; } else { fprintf (stderr, "Unrecognized option: %s\n", argv[i]); return 1; @@ -833,6 +836,12 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config); db_path = notmuch_config_get_database_path (config); + if (run_hooks) { + ret = notmuch_run_hook (db_path, "pre-new"); + if (ret) + return ret; + } + dot_notmuch_path = talloc_asprintf (ctx, "%s/%s", db_path, ".notmuch"); if (stat (dot_notmuch_path, &st)) { @@ -981,5 +990,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) notmuch_database_close (notmuch); + if (run_hooks && !ret && !interrupted) + ret = notmuch_run_hook (db_path, "post-new"); + return ret || interrupted; }