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 1E51C431FCF
\r
6 for <notmuch@notmuchmail.org>; Fri, 3 Oct 2014 07:20:19 -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 BZSI2emUxEFO for <notmuch@notmuchmail.org>;
\r
16 Fri, 3 Oct 2014 07:20:11 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.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 8B405431FDE
\r
22 for <notmuch@notmuchmail.org>; Fri, 3 Oct 2014 07:19:36 -0700 (PDT)
\r
23 X-AuditID: 12074425-f79e46d000002583-44-542eb0751d50
\r
24 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\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-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id 91.28.09603.570BE245; Fri, 3 Oct 2014 10:19:33 -0400 (EDT)
\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
30 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s93EJNje020194;
\r
31 Fri, 3 Oct 2014 10:19:23 -0400
\r
32 Received: from drake.dyndns.org
\r
33 (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
34 [216.15.114.40]) (authenticated bits=0)
\r
35 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
36 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s93EJLwW023306
\r
37 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT);
\r
38 Fri, 3 Oct 2014 10:19:22 -0400
\r
39 Received: from amthrax by drake.dyndns.org with local (Exim 4.84)
\r
40 (envelope-from <aclements@csail.mit.edu>)
\r
41 id 1Xa3hY-0002JY-VT; Fri, 03 Oct 2014 10:19:20 -0400
\r
42 From: Austin Clements <aclements@csail.mit.edu>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH 01/11] lib: Move message ID compression to
\r
45 _notmuch_message_create_for_message_id
\r
46 Date: Fri, 3 Oct 2014 10:19:08 -0400
\r
47 Message-Id: <1412345958-8278-2-git-send-email-aclements@csail.mit.edu>
\r
48 X-Mailer: git-send-email 2.1.0
\r
49 In-Reply-To: <1412345958-8278-1-git-send-email-aclements@csail.mit.edu>
\r
50 References: <1412345958-8278-1-git-send-email-aclements@csail.mit.edu>
\r
51 X-Brightmail-Tracker:
\r
52 H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsUixG6nrlu6QS/EoLXBwuL6zZnMDowez1bd
\r
53 Yg5gjOKySUnNySxLLdK3S+DKWPlXr2CbVMWT+RtYGxiPi3YxcnJICJhIPD98nw3CFpO4cG89
\r
54 mC0kMJtJYt+9ui5GLiB7A6NE+83jzBCJ20wSC9/KQiSWMEq83NjPCJJgE9CXWLF2EiuILSIg
\r
55 LbHz7mwgm4ODWUBN4k+XCogpLJAoMXlSDUgFi4CqxJE9rWDVvAJuEld3TmSBuEFOYsPu/2AT
\r
56 OQXcJS7cfQp1j5vEqmPdbBMY+RcwMqxilE3JrdLNTczMKU5N1i1OTszLSy3StdDLzSzRS00p
\r
57 3cQIDhcX1R2MEw4pHWIU4GBU4uH9eEM3RIg1say4MvcQoyQHk5Iob+VivRAhvqT8lMqMxOKM
\r
58 +KLSnNTiQ4wSHMxKIrwLVgLleFMSK6tSi/JhUtIcLErivJt+8IUICaQnlqRmp6YWpBbBZGU4
\r
59 OJQkeLmAcSEkWJSanlqRlplTgpBm4uAEGc4DNLx9Pcjw4oLE3OLMdIj8KUZFKXFeUZBmAZBE
\r
60 RmkeXC8snl8xigO9IszLBFLFA0wFcN2vgAYzAQ1+Z68LMrgkESEl1cB4YbMg++NiDzuVf8Gc
\r
61 daJ1y5js9wtbTsyIPVS9wvJPro346ndnPRmeaDzneHauzfP9+4/H5EKeCm75N+2/o7RvVs8R
\r
62 DafEdtajFUHpjT96pjtNMi1av3CZqO9Spr3zD9d++hza8iCiJoHPWGu36+qzviuu+QieWjZX
\r
63 6+Oq2yFVzc+X6U9qbPinxFKckWioxVxUnAgAtz0vOsICAAA=
\r
64 X-BeenThere: notmuch@notmuchmail.org
\r
65 X-Mailman-Version: 2.1.13
\r
67 List-Id: "Use and development of the notmuch mail system."
\r
68 <notmuch.notmuchmail.org>
\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
72 List-Post: <mailto:notmuch@notmuchmail.org>
\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
75 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
76 X-List-Received-Date: Fri, 03 Oct 2014 14:20:19 -0000
\r
78 From: Austin Clements <amdragon@mit.edu>
\r
80 Previously, this was performed by notmuch_database_add_message. This
\r
81 happens to be the only caller currently (which is why this was safe),
\r
82 but we're about to introduce more callers, and it makes more sense to
\r
83 put responsibility for ID compression in the lower-level function
\r
84 rather than requiring each caller to handle it.
\r
86 lib/database.cc | 16 ++++------------
\r
87 lib/message.cc | 4 ++++
\r
88 lib/notmuch-private.h | 3 +++
\r
89 3 files changed, 11 insertions(+), 12 deletions(-)
\r
91 diff --git a/lib/database.cc b/lib/database.cc
\r
92 index a47a71d..4e68706 100644
\r
93 --- a/lib/database.cc
\r
94 +++ b/lib/database.cc
\r
95 @@ -390,8 +390,8 @@ find_document_for_doc_id (notmuch_database_t *notmuch, unsigned doc_id)
\r
97 * notmuch-sha1-<sha1_sum_of_message_id>
\r
100 -_message_id_compressed (void *ctx, const char *message_id)
\r
102 +_notmuch_message_id_compressed (void *ctx, const char *message_id)
\r
104 char *sha1, *compressed;
\r
106 @@ -415,7 +415,7 @@ notmuch_database_find_message (notmuch_database_t *notmuch,
\r
107 return NOTMUCH_STATUS_NULL_POINTER;
\r
109 if (strlen (message_id) > NOTMUCH_MESSAGE_ID_MAX)
\r
110 - message_id = _message_id_compressed (notmuch, message_id);
\r
111 + message_id = _notmuch_message_id_compressed (notmuch, message_id);
\r
114 status = _notmuch_database_find_unique_doc_id (notmuch, "id",
\r
115 @@ -1728,7 +1728,7 @@ static char *
\r
116 _get_metadata_thread_id_key (void *ctx, const char *message_id)
\r
118 if (strlen (message_id) > NOTMUCH_MESSAGE_ID_MAX)
\r
119 - message_id = _message_id_compressed (ctx, message_id);
\r
120 + message_id = _notmuch_message_id_compressed (ctx, message_id);
\r
122 return talloc_asprintf (ctx, NOTMUCH_METADATA_THREAD_ID_PREFIX "%s",
\r
124 @@ -2100,14 +2100,6 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
125 * better than no message-id at all. */
\r
126 if (message_id == NULL)
\r
127 message_id = talloc_strdup (message_file, header);
\r
129 - /* If a message ID is too long, substitute its sha1 instead. */
\r
130 - if (message_id && strlen (message_id) > NOTMUCH_MESSAGE_ID_MAX) {
\r
131 - char *compressed = _message_id_compressed (message_file,
\r
133 - talloc_free (message_id);
\r
134 - message_id = compressed;
\r
138 if (message_id == NULL ) {
\r
139 diff --git a/lib/message.cc b/lib/message.cc
\r
140 index 7e82548..bbfc250 100644
\r
141 --- a/lib/message.cc
\r
142 +++ b/lib/message.cc
\r
143 @@ -226,6 +226,10 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch,
\r
144 else if (*status_ret)
\r
147 + /* If the message ID is too long, substitute its sha1 instead. */
\r
148 + if (strlen (message_id) > NOTMUCH_MESSAGE_ID_MAX)
\r
149 + message_id = _notmuch_message_id_compressed (message, message_id);
\r
151 term = talloc_asprintf (NULL, "%s%s",
\r
152 _find_prefix ("id"), message_id);
\r
153 if (term == NULL) {
\r
154 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
155 index 17f3061..36cc12b 100644
\r
156 --- a/lib/notmuch-private.h
\r
157 +++ b/lib/notmuch-private.h
\r
158 @@ -174,6 +174,9 @@ typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t;
\r
160 _find_prefix (const char *name);
\r
163 +_notmuch_message_id_compressed (void *ctx, const char *message_id);
\r
166 _notmuch_database_ensure_writable (notmuch_database_t *notmuch);
\r