1 Return-Path: <amdragon@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 1A1D2431FAF
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 22:17:45 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 ZtnqlEfSeZH5 for <notmuch@notmuchmail.org>;
\r
16 Sat, 24 Nov 2012 22:17:44 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 152CB431FAE
\r
20 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 22:17:43 -0800 (PST)
\r
21 X-AuditID: 1209190e-b7f756d000000904-78-50b1b8079998
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 77.1B.02308.708B1B05; Sun, 25 Nov 2012 01:17:43 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qAP6G5jY005391;
\r
27 Sun, 25 Nov 2012 01:16:05 -0500
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAP6G3I1006919
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sun, 25 Nov 2012 01:16:04 -0500 (EST)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1TcVVb-0008HQ-AG; Sun, 25 Nov 2012 01:16:03 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 3/3] lib: Reject multi-message mboxes and deprecate
\r
42 Date: Sun, 25 Nov 2012 01:16:01 -0500
\r
43 Message-Id: <1353824161-31717-3-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.10.4
\r
45 In-Reply-To: <1353824161-31717-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1353824161-31717-1-git-send-email-amdragon@mit.edu>
\r
47 X-Brightmail-Tracker:
\r
48 H4sIAAAAAAAAA+NgFtrHIsWRmVeSWpSXmKPExsUixCmqrMu+Y2OAwfr1yhY3WrsZLa7fnMns
\r
49 wOTxbNUtZo8th94zBzBFcdmkpOZklqUW6dslcGV0tjWxFqyWr3i7+xRjA+MEyS5GTg4JAROJ
\r
50 e41T2SBsMYkL99YD2VwcQgL7GCUubO2CcjYwSky+OZ8RwnnEJDHp7UsWCGcuo8TsW7MZQfrZ
\r
51 BDQktu1fDmaLCEhL7Lw7mxXEZhawlLj6tZ0JxBYWCJfo+twDto9FQFXiQOMGsHpeAQeJz6/+
\r
52 skDcoSjR/WwCWA2ngKPEwr4DYLYQUM35ycdZJjDyL2BkWMUom5JbpZubmJlTnJqsW5ycmJeX
\r
53 WqRrrJebWaKXmlK6iREcTJJ8Oxi/HlQ6xCjAwajEw3sjcWOAEGtiWXFl7iFGSQ4mJVHeqZuB
\r
54 QnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR4D6wFyvGmJFZWpRblw6SkOViUxHmvpNz0FxJITyxJ
\r
55 zU5NLUgtgsnKcHAoSfBu3wrUKFiUmp5akZaZU4KQZuLgBBnOAzR80TaQ4cUFibnFmekQ+VOM
\r
56 ilLivBNBEgIgiYzSPLheWLS/YhQHekWYNwGkigeYKOC6XwENZgIa/HT2OpDBJYkIKakGRlHW
\r
57 d9YM1+NaTj6OOfjshGXnk1/Bh7VLdyUsyv7zraonbsctrvzuV1/v7JrCt3yCenzVcb5Gu4NT
\r
58 3zYWpN7SZD/OyLs/c5nZ9Xfca2aocRZ+9TQuTpwWfMu54vINLctFD5ZLPhOIXyGvfuWQg7rL
\r
59 grDL2ZfX6a1pera/96L+UrGqQ07tHpHM65RYijMSDbWYi4oTAREvBKTRAgAA
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Sun, 25 Nov 2012 06:17:45 -0000
\r
74 Previously, we would treat multi-message mboxes as one giant email,
\r
75 which, besides the obvious incorrect indexing, often led to
\r
76 out-of-memory errors for archival mboxes. Now we explicitly reject
\r
77 multi-message mboxes. For historical reasons, we retain support for
\r
78 single-message mboxes, but official deprecate this behavior.
\r
80 lib/database.cc | 4 +++-
\r
81 lib/index.cc | 28 ++++++++++++++++++++++++++++
\r
82 test/new | 8 +++++---
\r
83 3 files changed, 36 insertions(+), 4 deletions(-)
\r
85 diff --git a/lib/database.cc b/lib/database.cc
\r
86 index 4df3217..91d4329 100644
\r
87 --- a/lib/database.cc
\r
88 +++ b/lib/database.cc
\r
89 @@ -1821,7 +1821,9 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
90 date = notmuch_message_file_get_header (message_file, "date");
\r
91 _notmuch_message_set_header_values (message, date, from, subject);
\r
93 - _notmuch_message_index_file (message, filename);
\r
94 + ret = _notmuch_message_index_file (message, filename);
\r
98 ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
\r
100 diff --git a/lib/index.cc b/lib/index.cc
\r
101 index e377732..da0e6ce 100644
\r
104 @@ -435,6 +435,9 @@ _notmuch_message_index_file (notmuch_message_t *message,
\r
105 const char *from, *subject;
\r
106 notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
\r
107 static int initialized = 0;
\r
108 + char from_buf[5];
\r
109 + bool is_mbox = false;
\r
110 + static bool mbox_warning = false;
\r
112 if (! initialized) {
\r
114 @@ -448,13 +451,38 @@ _notmuch_message_index_file (notmuch_message_t *message,
\r
118 + /* Is this mbox? */
\r
119 + if (fread (from_buf, sizeof (from_buf), 1, file) == 1 &&
\r
120 + strncmp (from_buf, "From ", 5) == 0)
\r
124 /* Evil GMime steals my FILE* here so I won't fclose it. */
\r
125 stream = g_mime_stream_file_new (file);
\r
127 parser = g_mime_parser_new_with_stream (stream);
\r
128 + g_mime_parser_set_scan_from (parser, is_mbox);
\r
130 mime_message = g_mime_parser_construct_message (parser);
\r
133 + if (!g_mime_parser_eos (parser)) {
\r
134 + /* This is a multi-message mbox. */
\r
135 + ret = NOTMUCH_STATUS_FILE_NOT_EMAIL;
\r
138 + /* For historical reasons, we support single-message mboxes,
\r
139 + * but this behavior is likely to change in the future, so
\r
141 + if (!mbox_warning) {
\r
142 + mbox_warning = true;
\r
143 + fprintf (stderr, "\
\r
144 +Warning: %s is an mbox containing a single message,\n\
\r
145 +likely caused by misconfigured mail delivery. Support for single-message\n\
\r
146 +mboxes is deprecated and may be removed in the future.\n", filename);
\r
150 from = g_mime_message_get_sender (mime_message);
\r
151 addresses = internet_address_list_parse_string (from);
\r
153 diff --git a/test/new b/test/new
\r
154 index 29f9aff..f562cec 100755
\r
157 @@ -163,7 +163,7 @@ rm -rf "${MAIL_DIR}"/two
\r
158 output=$(NOTMUCH_NEW)
\r
159 test_expect_equal "$output" "No new mail. Removed 3 messages."
\r
161 -test_begin_subtest "Support single-message mbox"
\r
162 +test_begin_subtest "Support single-message mbox (deprecated)"
\r
163 cat > "${MAIL_DIR}"/mbox_file1 <<EOF
\r
164 From test_suite@notmuchmail.org Fri Jan 5 15:43:57 2001
\r
165 From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
166 @@ -174,11 +174,13 @@ Body.
\r
168 output=$(NOTMUCH_NEW 2>&1)
\r
169 test_expect_equal "$output" \
\r
170 -"Added 1 new message to the database."
\r
171 +"Warning: ${MAIL_DIR}/mbox_file1 is an mbox containing a single message,
\r
172 +likely caused by misconfigured mail delivery. Support for single-message
\r
173 +mboxes is deprecated and may be removed in the future.
\r
174 +Added 1 new message to the database."
\r
176 # This test requires that notmuch new has been run at least once.
\r
177 test_begin_subtest "Skip and report non-mail files"
\r
178 -test_subtest_known_broken
\r
180 mkdir -p "${MAIL_DIR}"/.git && touch "${MAIL_DIR}"/.git/config
\r
181 touch "${MAIL_DIR}"/ignored_file
\r