X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-new.c;h=3512de727734ad48025f3f88972587fed91d838b;hp=96a1e31e732da0b4d16cbdc374848d810904eb96;hb=baa2c9721d850ea95857f44ba0b44147c80f7998;hpb=02a30767116ad8abcbd0a3351f2e4d43bbbd655f diff --git a/notmuch-new.c b/notmuch-new.c index 96a1e31e..3512de72 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -67,7 +67,7 @@ handle_sigint (unused (int sig)) { static char msg[] = "Stopping... \n"; - write(2, msg, sizeof(msg)-1); + (void) write(2, msg, sizeof(msg)-1); interrupted = 1; } @@ -811,13 +811,18 @@ 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)); + argc--; argv++; /* skip subcommand argument */ + 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; @@ -831,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)) { @@ -979,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; }