1 Return-Path: <aclements@csail.mit.edu>
\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 olra.theworths.org (Postfix) with ESMTP id 17CAB431FB6
\r
6 for <notmuch@notmuchmail.org>; Mon, 6 Oct 2014 16:18:08 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 2EsvOc-w5aPh for <notmuch@notmuchmail.org>;
\r
16 Mon, 6 Oct 2014 16:18:04 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 6CEA5431FAE
\r
22 for <notmuch@notmuchmail.org>; Mon, 6 Oct 2014 16:17:40 -0700 (PDT)
\r
23 X-AuditID: 1209190e-f79d46d000003643-68-543323132dd7
\r
24 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
25 (using TLS with cipher AES256-SHA (256/256 bits))
\r
26 (Client did not present a certificate)
\r
27 by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id CD.5D.13891.31323345; Mon, 6 Oct 2014 19:17:39 -0400 (EDT)
\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
30 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s96NHT81030746;
\r
31 Mon, 6 Oct 2014 19:17:29 -0400
\r
32 Received: from drake.dyndns.org ([12.185.136.2]) (authenticated bits=0)
\r
33 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
34 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s96NHRec014546
\r
35 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT);
\r
36 Mon, 6 Oct 2014 19:17:28 -0400
\r
37 Received: from amthrax by drake.dyndns.org with local (Exim 4.84)
\r
38 (envelope-from <aclements@csail.mit.edu>)
\r
39 id 1XbHWr-0001JI-GX; Mon, 06 Oct 2014 17:17:21 -0600
\r
40 From: Austin Clements <aclements@csail.mit.edu>
\r
41 To: notmuch@notmuchmail.org
\r
42 Subject: [PATCH v2 01/12] lib: Move message ID compression to
\r
43 _notmuch_message_create_for_message_id
\r
44 Date: Mon, 6 Oct 2014 17:17:07 -0600
\r
45 Message-Id: <1412637438-4821-2-git-send-email-aclements@csail.mit.edu>
\r
46 X-Mailer: git-send-email 2.1.0
\r
47 In-Reply-To: <1412637438-4821-1-git-send-email-aclements@csail.mit.edu>
\r
48 References: <1412637438-4821-1-git-send-email-aclements@csail.mit.edu>
\r
49 X-Brightmail-Tracker:
\r
50 H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixCmqrSusbBxiMOmGscWN1m5Gi+s3ZzI7
\r
51 MHk8W3WL2WPLoffMAUxRXDYpqTmZZalF+nYJXBkr/+oVbJOqeDJ/A2sD43HRLkZODgkBE4lP
\r
52 sw6wQ9hiEhfurWfrYuTiEBKYzSRx4e55ZghnA6PEklkLoZylTBKP+/rYIZwljBLTpq5gAeln
\r
53 E9CXWLF2EiuILSIgLbHz7mwwm1nAUuLq13YmEFtYIEXixv5VYPUsAqoSl5t72EBsXgE3iTn7
\r
54 PrNA3CEnsWH3f0YQm1PAXWLNlclgc4SAap7/fMoygZF/ASPDKkbZlNwq3dzEzJzi1GTd4uTE
\r
55 vLzUIl1jvdzMEr3UlNJNjOBQkuTbwfj1oNIhRgEORiUe3ogdhiFCrIllxZW5hxglOZiURHnn
\r
56 sBuHCPEl5adUZiQWZ8QXleakFh9ilOBgVhLh5fptFCLEm5JYWZValA+TkuZgURLn3fSDL0RI
\r
57 ID2xJDU7NbUgtQgmK8PBoSTB+1sRaKhgUWp6akVaZk4JQpqJgxNkOA/Q8H8gNbzFBYm5xZnp
\r
58 EPlTjIpS4rzJSkAJAZBERmkeXC8s1l8xigO9IswrDlLFA0wTcN2vgAYzAQ02naMPMrgkESEl
\r
59 1cC42oe5aRlPmk3DjBU5uasPrHz5Y/UymaTk+bLfDpv2GtuXr2IqNnWdvWrjbqHABiXJ5zZr
\r
60 2+ecT7k7abV1cOpsEanjjPvS+z+1W/eeFr/2YqaNb96s49G7Oz1tDzJO/q7hETTNbs2cbGdl
\r
61 s/VvjOf0LvN9fHjnDYlsoe87r5UEbM/XubqJl/u3EktxRqKhFnNRcSIAnhRx09ACAAA=
\r
62 X-BeenThere: notmuch@notmuchmail.org
\r
63 X-Mailman-Version: 2.1.13
\r
65 List-Id: "Use and development of the notmuch mail system."
\r
66 <notmuch.notmuchmail.org>
\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
70 List-Post: <mailto:notmuch@notmuchmail.org>
\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
73 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
74 X-List-Received-Date: Mon, 06 Oct 2014 23:18:08 -0000
\r
76 From: Austin Clements <amdragon@mit.edu>
\r
78 Previously, this was performed by notmuch_database_add_message. This
\r
79 happens to be the only caller currently (which is why this was safe),
\r
80 but we're about to introduce more callers, and it makes more sense to
\r
81 put responsibility for ID compression in the lower-level function
\r
82 rather than requiring each caller to handle it.
\r
84 lib/database.cc | 16 ++++------------
\r
85 lib/message.cc | 4 ++++
\r
86 lib/notmuch-private.h | 3 +++
\r
87 3 files changed, 11 insertions(+), 12 deletions(-)
\r
89 diff --git a/lib/database.cc b/lib/database.cc
\r
90 index a47a71d..4e68706 100644
\r
91 --- a/lib/database.cc
\r
92 +++ b/lib/database.cc
\r
93 @@ -390,8 +390,8 @@ find_document_for_doc_id (notmuch_database_t *notmuch, unsigned doc_id)
\r
95 * notmuch-sha1-<sha1_sum_of_message_id>
\r
98 -_message_id_compressed (void *ctx, const char *message_id)
\r
100 +_notmuch_message_id_compressed (void *ctx, const char *message_id)
\r
102 char *sha1, *compressed;
\r
104 @@ -415,7 +415,7 @@ notmuch_database_find_message (notmuch_database_t *notmuch,
\r
105 return NOTMUCH_STATUS_NULL_POINTER;
\r
107 if (strlen (message_id) > NOTMUCH_MESSAGE_ID_MAX)
\r
108 - message_id = _message_id_compressed (notmuch, message_id);
\r
109 + message_id = _notmuch_message_id_compressed (notmuch, message_id);
\r
112 status = _notmuch_database_find_unique_doc_id (notmuch, "id",
\r
113 @@ -1728,7 +1728,7 @@ static char *
\r
114 _get_metadata_thread_id_key (void *ctx, const char *message_id)
\r
116 if (strlen (message_id) > NOTMUCH_MESSAGE_ID_MAX)
\r
117 - message_id = _message_id_compressed (ctx, message_id);
\r
118 + message_id = _notmuch_message_id_compressed (ctx, message_id);
\r
120 return talloc_asprintf (ctx, NOTMUCH_METADATA_THREAD_ID_PREFIX "%s",
\r
122 @@ -2100,14 +2100,6 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
123 * better than no message-id at all. */
\r
124 if (message_id == NULL)
\r
125 message_id = talloc_strdup (message_file, header);
\r
127 - /* If a message ID is too long, substitute its sha1 instead. */
\r
128 - if (message_id && strlen (message_id) > NOTMUCH_MESSAGE_ID_MAX) {
\r
129 - char *compressed = _message_id_compressed (message_file,
\r
131 - talloc_free (message_id);
\r
132 - message_id = compressed;
\r
136 if (message_id == NULL ) {
\r
137 diff --git a/lib/message.cc b/lib/message.cc
\r
138 index 7e82548..bbfc250 100644
\r
139 --- a/lib/message.cc
\r
140 +++ b/lib/message.cc
\r
141 @@ -226,6 +226,10 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch,
\r
142 else if (*status_ret)
\r
145 + /* If the message ID is too long, substitute its sha1 instead. */
\r
146 + if (strlen (message_id) > NOTMUCH_MESSAGE_ID_MAX)
\r
147 + message_id = _notmuch_message_id_compressed (message, message_id);
\r
149 term = talloc_asprintf (NULL, "%s%s",
\r
150 _find_prefix ("id"), message_id);
\r
151 if (term == NULL) {
\r
152 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
153 index 17f3061..36cc12b 100644
\r
154 --- a/lib/notmuch-private.h
\r
155 +++ b/lib/notmuch-private.h
\r
156 @@ -174,6 +174,9 @@ typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t;
\r
158 _find_prefix (const char *name);
\r
161 +_notmuch_message_id_compressed (void *ctx, const char *message_id);
\r
164 _notmuch_database_ensure_writable (notmuch_database_t *notmuch);
\r