From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id B3ED46DE02DD for ; Fri, 1 Apr 2016 18:50:29 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YRAGzcKQhmN8 for ; Fri, 1 Apr 2016 18:50:21 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108]) by arlo.cworth.org (Postfix) with ESMTP id 994166DE0281 for ; Fri, 1 Apr 2016 18:50:16 -0700 (PDT) Received: from fifthhorseman.net (unknown [190.172.4.74]) by che.mayfirst.org (Postfix) with ESMTPSA id 3C305F99D for ; Fri, 1 Apr 2016 21:50:15 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id 83EFD203D9; Fri, 1 Apr 2016 20:31:55 -0300 (BRT) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH 2/2] fix thread breakage via ghost-on-removal Date: Fri, 1 Apr 2016 20:31:55 -0300 Message-Id: <1459553515-18802-2-git-send-email-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1459553515-18802-1-git-send-email-dkg@fifthhorseman.net> References: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net> <1459553515-18802-1-git-send-email-dkg@fifthhorseman.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2016 01:50:29 -0000 This is the solution to T590-thread-breakage.sh that just adds a ghost message after removing each message. It leaks information about whether we've ever seen a given message id, but it's a fairly simple implementation. Note that _resolve_message_id_to_thread_id also introduces new message_ids to the database, so i think just searching for a given message ID may introduce the same metadata leakage. --- lib/database.cc | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index 3b342f1..6c9e34a 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -2557,9 +2557,33 @@ notmuch_database_remove_message (notmuch_database_t *notmuch, if (status == NOTMUCH_STATUS_SUCCESS && message) { status = _notmuch_message_remove_filename (message, filename); - if (status == NOTMUCH_STATUS_SUCCESS) + if (status == NOTMUCH_STATUS_SUCCESS) { + const char *mid, *tid; + notmuch_message_t *ghost; + notmuch_private_status_t private_status; + + mid = notmuch_message_get_message_id (message); + tid = notmuch_message_get_thread_id (message); + /* remove the message */ _notmuch_message_delete (message); - else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) + + /* and reintroduce a ghost in its place */ + ghost = _notmuch_message_create_for_message_id (notmuch, mid, &private_status); + if (private_status == NOTMUCH_PRIVATE_STATUS_SUCCESS) { + /* this is deeply weird, and we should not have + gotten into this state. is there a better + error message to return here? */ + status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID; + } else if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) { + private_status = _notmuch_message_initialize_ghost (ghost, tid); + if (! private_status) { + _notmuch_message_sync (ghost); + notmuch_message_destroy (ghost); + } + } + + status = COERCE_STATUS (private_status, "Error converting to ghost message"); + } else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) _notmuch_message_sync (message); notmuch_message_destroy (message); -- 2.8.0.rc3