[PATCH v2 12/14] cli/reply: pass internet address list to munge detect
[notmuch-archives.git] / ad / ba16ca11b3a8525627ed170b0189fe03830a10
1 Return-Path: <dkg@fifthhorseman.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id B3ED46DE02DD\r
6  for <notmuch@notmuchmail.org>; Fri,  1 Apr 2016 18:50:29 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12  autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id YRAGzcKQhmN8 for <notmuch@notmuchmail.org>;\r
16  Fri,  1 Apr 2016 18:50:21 -0700 (PDT)\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
18  by arlo.cworth.org (Postfix) with ESMTP id 994166DE0281\r
19  for <notmuch@notmuchmail.org>; Fri,  1 Apr 2016 18:50:16 -0700 (PDT)\r
20 Received: from fifthhorseman.net (unknown [190.172.4.74])\r
21  by che.mayfirst.org (Postfix) with ESMTPSA id 3C305F99D\r
22  for <notmuch@notmuchmail.org>; Fri,  1 Apr 2016 21:50:15 -0400 (EDT)\r
23 Received: by fifthhorseman.net (Postfix, from userid 1000)\r
24  id 83EFD203D9; Fri,  1 Apr 2016 20:31:55 -0300 (BRT)\r
25 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
26 To: Notmuch Mail <notmuch@notmuchmail.org>\r
27 Subject: [PATCH 2/2] fix thread breakage via ghost-on-removal\r
28 Date: Fri,  1 Apr 2016 20:31:55 -0300\r
29 Message-Id: <1459553515-18802-2-git-send-email-dkg@fifthhorseman.net>\r
30 X-Mailer: git-send-email 2.8.0.rc3\r
31 In-Reply-To: <1459553515-18802-1-git-send-email-dkg@fifthhorseman.net>\r
32 References: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net>\r
33  <1459553515-18802-1-git-send-email-dkg@fifthhorseman.net>\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.20\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38  <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
40  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sat, 02 Apr 2016 01:50:29 -0000\r
47 \r
48 This is the solution to T590-thread-breakage.sh that just adds a ghost\r
49 message after removing each message.\r
50 \r
51 It leaks information about whether we've ever seen a given message id,\r
52 but it's a fairly simple implementation.\r
53 \r
54 Note that _resolve_message_id_to_thread_id also introduces new\r
55 message_ids to the database, so i think just searching for a given\r
56 message ID may introduce the same metadata leakage.\r
57 ---\r
58  lib/database.cc | 28 ++++++++++++++++++++++++++--\r
59  1 file changed, 26 insertions(+), 2 deletions(-)\r
60 \r
61 diff --git a/lib/database.cc b/lib/database.cc\r
62 index 3b342f1..6c9e34a 100644\r
63 --- a/lib/database.cc\r
64 +++ b/lib/database.cc\r
65 @@ -2557,9 +2557,33 @@ notmuch_database_remove_message (notmuch_database_t *notmuch,\r
66  \r
67      if (status == NOTMUCH_STATUS_SUCCESS && message) {\r
68             status = _notmuch_message_remove_filename (message, filename);\r
69 -           if (status == NOTMUCH_STATUS_SUCCESS)\r
70 +           if (status == NOTMUCH_STATUS_SUCCESS) {\r
71 +               const char *mid, *tid;\r
72 +               notmuch_message_t *ghost;\r
73 +               notmuch_private_status_t private_status;\r
74 +           \r
75 +               mid = notmuch_message_get_message_id (message);\r
76 +               tid = notmuch_message_get_thread_id (message);\r
77 +               /* remove the message */\r
78                 _notmuch_message_delete (message);\r
79 -           else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID)\r
80 +           \r
81 +               /* and reintroduce a ghost in its place */\r
82 +               ghost = _notmuch_message_create_for_message_id (notmuch, mid, &private_status);\r
83 +               if (private_status == NOTMUCH_PRIVATE_STATUS_SUCCESS) {\r
84 +                   /* this is deeply weird, and we should not have\r
85 +                      gotten into this state.  is there a better\r
86 +                      error message to return here? */\r
87 +                   status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;\r
88 +               } else if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {\r
89 +                   private_status = _notmuch_message_initialize_ghost (ghost, tid);\r
90 +                   if (! private_status) {\r
91 +                       _notmuch_message_sync (ghost);\r
92 +                       notmuch_message_destroy (ghost);\r
93 +                   }\r
94 +               }\r
95 +           \r
96 +               status = COERCE_STATUS (private_status, "Error converting to ghost message");\r
97 +           } else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID)\r
98                 _notmuch_message_sync (message);\r
99  \r
100             notmuch_message_destroy (message);\r
101 -- \r
102 2.8.0.rc3\r
103 \r