X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch.c;h=a7559fc7a6266a034f6b8580819ff0ca9a2be1e9;hp=0fc4433b8325a298e439b65c78ec48b3c7df05f9;hb=b0190e59ac14851a0b79a00d58aad2e8febea92f;hpb=89697201080cd8aa3196792be1d0cae45c782952 diff --git a/notmuch.c b/notmuch.c index 0fc4433b..a7559fc7 100644 --- a/notmuch.c +++ b/notmuch.c @@ -286,6 +286,7 @@ add_files_recursive (notmuch_database_t *notmuch, case NOTMUCH_STATUS_FILE_ERROR: case NOTMUCH_STATUS_NULL_POINTER: case NOTMUCH_STATUS_TAG_TOO_LONG: + case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: case NOTMUCH_STATUS_LAST_STATUS: INTERNAL_ERROR ("add_message returned unexpected value: %d", status); goto DONE; @@ -854,35 +855,34 @@ restore_command (int argc, char *argv[]) message = notmuch_database_find_message (notmuch, message_id); if (message == NULL) { - fprintf (stderr, "Warning: Cannot apply tags to missing message: %s (", + fprintf (stderr, "Warning: Cannot apply tags to missing message: %s\n", message_id); + goto NEXT_LINE; } + notmuch_message_freeze (message); + + notmuch_message_remove_all_tags (message); + next = tags; while (next) { tag = strsep (&next, " "); if (*tag == '\0') continue; - if (message) { - status = notmuch_message_add_tag (message, tag); - if (status) { - fprintf (stderr, - "Error applying tag %s to message %s:\n", - tag, message_id); - fprintf (stderr, "%s\n", - notmuch_status_to_string (status)); - } - } else { - fprintf (stderr, "%s%s", - tag == tags ? "" : " ", tag); + status = notmuch_message_add_tag (message, tag); + if (status) { + fprintf (stderr, + "Error applying tag %s to message %s:\n", + tag, message_id); + fprintf (stderr, "%s\n", + notmuch_status_to_string (status)); } } - if (message) - notmuch_message_destroy (message); - else - fprintf (stderr, ")\n"); + notmuch_message_thaw (message); + notmuch_message_destroy (message); } + NEXT_LINE: free (message_id); free (tags); }