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 8F8376DE02D9 for ; Sat, 2 Apr 2016 07:16:11 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.274 X-Spam-Level: X-Spam-Status: No, score=-0.274 tagged_above=-999 required=5 tests=[AWL=-0.274] 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 UDpM3KWR5O7w for ; Sat, 2 Apr 2016 07:16:04 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108]) by arlo.cworth.org (Postfix) with ESMTP id 9C1446DE02DA for ; Sat, 2 Apr 2016 07:15:50 -0700 (PDT) Received: from fifthhorseman.net (dhcp-a244.meeting.ietf.org [31.133.162.68]) by che.mayfirst.org (Postfix) with ESMTPSA id 16DD0F997 for ; Sat, 2 Apr 2016 10:15:49 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id BA72920CDE; Sat, 2 Apr 2016 11:15:41 -0300 (BRT) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH v2 7/7] complete ghost-on-removal-when-shared-thread-exists Date: Sat, 2 Apr 2016 11:15:41 -0300 Message-Id: <1459606541-23889-7-git-send-email-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1459606541-23889-1-git-send-email-dkg@fifthhorseman.net> References: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net> <1459606541-23889-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 14:16:11 -0000 To fully complete the ghost-on-removal-when-shared-thread-exists proposal, we need to clear all ghost messages when the last active message is removed from a thread. --- lib/message.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/message.cc b/lib/message.cc index f715e39..01daa56 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -1097,6 +1097,26 @@ _notmuch_message_delete (notmuch_message_t *message) } notmuch_message_destroy (ghost); status = COERCE_STATUS (private_status, "Error converting to ghost message"); + } else { + /* the thread is empty; drop all ghost messages from it */ + notmuch_messages_t *messages; + status = _notmuch_query_search_messages_type_st (query, + "ghost", + &messages); + if (status == NOTMUCH_STATUS_SUCCESS) { + notmuch_status_t last_error = NOTMUCH_STATUS_SUCCESS; + while (notmuch_messages_valid (messages)) { + message = notmuch_messages_get (messages); + status = _notmuch_message_delete (message); + if (status) /* we'll report the last failure we see; + * if there is more than one failure, we + * forget about previous ones */ + last_error = status; + notmuch_message_destroy (message); + notmuch_messages_move_to_next (messages); + } + status = last_error; + } } notmuch_query_destroy (query); return status; -- 2.8.0.rc3