aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-new.c
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@mit.edu>2011-01-29 11:25:56 -0500
committerGravatar David Bremner <bremner@debian.org>2011-09-24 20:00:29 -0300
commitbff30540d86c77aacbc2c133c83aa7ccee823b48 (patch)
tree2868e7ae03ff81ea958a016d2984723c99becea0 /notmuch-new.c
parent8305f0aac7f31aeddd54d0af683475ab1492e2b7 (diff)
new: Wrap adding and removing messages in atomic sections.
This addresses atomicity of tag synchronization, the last atomicity problems in notmuch new. Each message add or remove is wrapped in its own atomic section, so interrupting notmuch new doesn't lose progress.
Diffstat (limited to 'notmuch-new.c')
-rw-r--r--notmuch-new.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/notmuch-new.c b/notmuch-new.c
index 598a2083..e79593cd 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,6 +740,9 @@ remove_filename (notmuch_database_t *notmuch,
{
notmuch_status_t status;
notmuch_message_t *message;
+ status = notmuch_database_begin_atomic (notmuch);
+ if (status)
+ return status;
message = notmuch_database_find_message_by_filename (notmuch, path);
status = notmuch_database_remove_message (notmuch, path);
if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
@@ -737,6 +752,7 @@ remove_filename (notmuch_database_t *notmuch,
} else
add_files_state->removed_messages++;
notmuch_message_destroy (message);
+ notmuch_database_end_atomic (notmuch);
return status;
}