X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-new.c;h=81a93500ced96e971df3562a3730e911f81819e1;hp=598a2083ffaec689285878a6a4b873d8d6f4b245;hb=ed20210b6db0b237d48765351cb99b87be7a0509;hpb=8305f0aac7f31aeddd54d0af683475ab1492e2b7 diff --git a/notmuch-new.c b/notmuch-new.c index 598a2083..81a93500 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -450,6 +450,12 @@ add_files_recursive (notmuch_database_t *notmuch, fflush (stdout); } + status = notmuch_database_begin_atomic (notmuch); + if (status) { + ret = status; + goto DONE; + } + status = notmuch_database_add_message (notmuch, next, &message); switch (status) { /* success */ @@ -490,6 +496,12 @@ add_files_recursive (notmuch_database_t *notmuch, goto DONE; } + status = notmuch_database_end_atomic (notmuch); + if (status) { + ret = status; + goto DONE; + } + if (message) { notmuch_message_destroy (message); message = NULL; @@ -728,7 +740,12 @@ remove_filename (notmuch_database_t *notmuch, { notmuch_status_t status; notmuch_message_t *message; - message = notmuch_database_find_message_by_filename (notmuch, path); + status = notmuch_database_begin_atomic (notmuch); + if (status) + return status; + status = notmuch_database_find_message_by_filename (notmuch, path, &message); + if (status || message == NULL) + return status; status = notmuch_database_remove_message (notmuch, path); if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) { add_files_state->renamed_messages++; @@ -737,6 +754,7 @@ remove_filename (notmuch_database_t *notmuch, } else add_files_state->removed_messages++; notmuch_message_destroy (message); + notmuch_database_end_atomic (notmuch); return status; } @@ -797,6 +815,8 @@ notmuch_new_command (void *ctx, int argc, char *argv[]) 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;