This prevents atomicity violations when adding new messages. Each message add is wrapped in its own atomic section, so interrupting notmuch new doesn't loose progress. Unlike in the remove case, adding a message can modify more than one database document, necessitating full transactions. --- notmuch-new.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index 767722a..880f31a 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -424,6 +424,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 */ @@ -463,6 +469,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; -- 1.7.2.3