]> git.notmuchmail.org Git - notmuch/commitdiff
new: Fix missing end_atomic in remove_filename on error
authorAustin Clements <amdragon@MIT.EDU>
Sun, 22 Apr 2012 15:50:52 +0000 (11:50 -0400)
committerDavid Bremner <bremner@debian.org>
Wed, 25 Apr 2012 02:25:52 +0000 (23:25 -0300)
Previously, if we failed to find the message by filename in
remove_filename, we would return immediately from the function without
ending its atomic block.  Now this code follows the usual goto DONE
idiom to perform cleanup.

notmuch-new.c

index bf9b120949b6697650a681eb5c566b0e97bbfccb..473201e961cdb61fe51c1807a18b4161d3615f48 100644 (file)
@@ -779,7 +779,8 @@ remove_filename (notmuch_database_t *notmuch,
        return status;
     status = notmuch_database_find_message_by_filename (notmuch, path, &message);
     if (status || message == NULL)
-       return status;
+       goto DONE;
+
     status = notmuch_database_remove_message (notmuch, path);
     if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
        add_files_state->renamed_messages++;
@@ -790,6 +791,8 @@ remove_filename (notmuch_database_t *notmuch,
        add_files_state->removed_messages++;
     }
     notmuch_message_destroy (message);
+
+  DONE:
     notmuch_database_end_atomic (notmuch);
     return status;
 }