1 Return-Path: <jani@nikula.org>
\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 75760431FBC
\r
6 for <notmuch@notmuchmail.org>; Wed, 4 Jun 2014 23:34:09 -0700 (PDT)
\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 k9LzwSGKY-Mu for <notmuch@notmuchmail.org>;
\r
16 Wed, 4 Jun 2014 23:34:01 -0700 (PDT)
\r
17 Received: from mail-we0-f172.google.com (mail-we0-f172.google.com
\r
18 [74.125.82.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 5B88B431FB6
\r
21 for <notmuch@notmuchmail.org>; Wed, 4 Jun 2014 23:34:01 -0700 (PDT)
\r
22 Received: by mail-we0-f172.google.com with SMTP id k48so532662wev.17
\r
23 for <notmuch@notmuchmail.org>; Wed, 04 Jun 2014 23:33:59 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=1e100.net; s=20130820;
\r
26 h=x-gm-message-state:from:to:cc:subject:date:message-id;
\r
27 bh=X02PNLURP2Abu/qUtRjTFSJkNCwLdcHDPXw7O1Es2kU=;
\r
28 b=RbSFhrJPsBj03qOzPywOJavZzijxQa6WwNtc+cOWEAcsEpbk7VlvtEJwltLQV2QM+l
\r
29 DQ80xGNTPwWfVxiu5BOnGgaXt/qT7sGsFEEOhWgY6h2M4jDTnQCGZ18i1p+a/N3NYSF0
\r
30 oH3eRMb2nWdnNk0kPUJXHNXiO5L4zVY+7iY+s6q0+1yUPcVZKlPyht5RJtG4SSvfcVVz
\r
31 romAid6CpCz0bJNIgEQoKOZ0QXjCO1ciPRme7yDHBK/3NEasYiS5dkjCVk0j45uD/sy6
\r
32 dcLmdEa6v0tCIyA0p7ZrRcKuNmCJ8zmSl+vvgkOj0bf7SHR5CYIrLCAWiml1HJRE+JVw
\r
35 ALoCoQkQreoi/toksieDz2U+qzKwo52wz4DcrgLOoVImwI2rXhvvyKGY/LX1PM0V6EKxQ9wxpOOd
\r
36 X-Received: by 10.194.81.98 with SMTP id z2mr79399580wjx.12.1401950038787;
\r
37 Wed, 04 Jun 2014 23:33:58 -0700 (PDT)
\r
38 Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])
\r
39 by mx.google.com with ESMTPSA id p15sm52305473wiv.8.2014.06.04.23.33.57
\r
40 for <multiple recipients>
\r
41 (version=TLSv1.1 cipher=RC4-SHA bits=128/128);
\r
42 Wed, 04 Jun 2014 23:33:58 -0700 (PDT)
\r
43 From: Jani Nikula <jani@nikula.org>
\r
44 To: notmuch@notmuchmail.org
\r
45 Subject: [PATCH] lib: resurrect support for single-message mbox files
\r
46 Date: Thu, 5 Jun 2014 08:34:09 +0200
\r
47 Message-Id: <1401950049-22351-1-git-send-email-jani@nikula.org>
\r
48 X-Mailer: git-send-email 1.7.2.5
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Thu, 05 Jun 2014 06:34:09 -0000
\r
63 This is effectively a revert of
\r
65 commit 6812136bf576d894591606d9e10096719054d1f9
\r
66 Author: Jani Nikula <jani@nikula.org>
\r
67 Date: Mon Mar 31 00:21:48 2014 +0300
\r
69 lib: drop support for single-message mbox files
\r
71 The intention was to drop support for indexing new single-message mbox
\r
72 files (and whether that was a good idea in the first place is
\r
73 arguable). However this inadvertently broke support for reading
\r
74 headers from previously indexed single-message mbox files, which is
\r
77 Distinguishing between the two cases would require more code than
\r
78 simply bringing back support for single-message mbox files.
\r
80 lib/message-file.c | 30 +++++++++++++++++++++++++-----
\r
81 test/T050-new.sh | 26 ++++++++++++++++----------
\r
82 2 files changed, 41 insertions(+), 15 deletions(-)
\r
84 diff --git a/lib/message-file.c b/lib/message-file.c
\r
85 index 6782882..483ba1e 100644
\r
86 --- a/lib/message-file.c
\r
87 +++ b/lib/message-file.c
\r
88 @@ -117,7 +117,7 @@ notmuch_message_file_close (notmuch_message_file_t *message)
\r
91 static notmuch_bool_t
\r
92 -is_mbox (FILE *file)
\r
93 +_is_mbox (FILE *file)
\r
96 notmuch_bool_t ret = FALSE;
\r
97 @@ -139,13 +139,12 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
\r
98 GMimeParser *parser;
\r
99 notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
\r
100 static int initialized = 0;
\r
101 + notmuch_bool_t is_mbox;
\r
103 if (message->message)
\r
104 return NOTMUCH_STATUS_SUCCESS;
\r
106 - /* We no longer support mboxes at all. */
\r
107 - if (is_mbox (message->file))
\r
108 - return NOTMUCH_STATUS_FILE_NOT_EMAIL;
\r
109 + is_mbox = _is_mbox (message->file);
\r
111 if (! initialized) {
\r
112 g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS);
\r
113 @@ -163,7 +162,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
\r
114 g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), FALSE);
\r
116 parser = g_mime_parser_new_with_stream (stream);
\r
117 - g_mime_parser_set_scan_from (parser, FALSE);
\r
118 + g_mime_parser_set_scan_from (parser, is_mbox);
\r
120 message->message = g_mime_parser_construct_message (parser);
\r
121 if (! message->message) {
\r
122 @@ -171,6 +170,27 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
\r
127 + if (! g_mime_parser_eos (parser)) {
\r
128 + /* This is a multi-message mbox. */
\r
129 + status = NOTMUCH_STATUS_FILE_NOT_EMAIL;
\r
133 + * For historical reasons, we support single-message mboxes,
\r
134 + * but this behavior is likely to change in the future, so
\r
137 + static notmuch_bool_t mbox_warning = FALSE;
\r
138 + if (! mbox_warning) {
\r
139 + mbox_warning = TRUE;
\r
140 + fprintf (stderr, "\
\r
141 +Warning: %s is an mbox containing a single message,\n\
\r
142 +likely caused by misconfigured mail delivery. Support for single-message\n\
\r
143 +mboxes is deprecated and may be removed in the future.\n", message->filename);
\r
148 g_object_unref (stream);
\r
149 g_object_unref (parser);
\r
150 diff --git a/test/T050-new.sh b/test/T050-new.sh
\r
151 index 3c31954..ad46ee6 100755
\r
152 --- a/test/T050-new.sh
\r
153 +++ b/test/T050-new.sh
\r
154 @@ -163,6 +163,22 @@ rm -rf "${MAIL_DIR}"/two
\r
155 output=$(NOTMUCH_NEW)
\r
156 test_expect_equal "$output" "No new mail. Removed 3 messages."
\r
158 +test_begin_subtest "Support single-message mbox (deprecated)"
\r
159 +cat > "${MAIL_DIR}"/mbox_file1 <<EOF
\r
160 +From test_suite@notmuchmail.org Fri Jan 5 15:43:57 2001
\r
161 +From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
162 +To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
163 +Subject: Test mbox message 1
\r
167 +output=$(NOTMUCH_NEW 2>&1)
\r
168 +test_expect_equal "$output" \
\r
169 +"Warning: ${MAIL_DIR}/mbox_file1 is an mbox containing a single message,
\r
170 +likely caused by misconfigured mail delivery. Support for single-message
\r
171 +mboxes is deprecated and may be removed in the future.
\r
172 +Added 1 new message to the database."
\r
174 # This test requires that notmuch new has been run at least once.
\r
175 test_begin_subtest "Skip and report non-mail files"
\r
177 @@ -184,24 +200,14 @@ Subject: Test mbox message 2
\r
181 -cat > "${MAIL_DIR}"/mbox_file1 <<EOF
\r
182 -From test_suite@notmuchmail.org Fri Jan 5 15:43:57 2001
\r
183 -From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
184 -To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
185 -Subject: Test mbox message 1
\r
189 output=$(NOTMUCH_NEW 2>&1)
\r
190 test_expect_equal "$output" \
\r
191 "Note: Ignoring non-mail file: ${MAIL_DIR}/.git/config
\r
192 Note: Ignoring non-mail file: ${MAIL_DIR}/.ignored_hidden_file
\r
193 Note: Ignoring non-mail file: ${MAIL_DIR}/ignored_file
\r
194 Note: Ignoring non-mail file: ${MAIL_DIR}/mbox_file
\r
195 -Note: Ignoring non-mail file: ${MAIL_DIR}/mbox_file1
\r
196 Added 1 new message to the database."
\r
197 rm "${MAIL_DIR}"/mbox_file
\r
198 -rm "${MAIL_DIR}"/mbox_file1
\r
200 test_begin_subtest "Ignore files and directories specified in new.ignore"
\r