database error
[notmuch-archives.git] / f4 / 78a0d6490686b447c7e2122257aceb79841258
1 Return-Path: <m.walters@qmul.ac.uk>\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 1E71240C42E\r
6         for <notmuch@notmuchmail.org>; Fri,  6 Jun 2014 05:36:34 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.502\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.502 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id bfVvS4TNIgZV for <notmuch@notmuchmail.org>;\r
17         Fri,  6 Jun 2014 05:36:26 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\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 372FF40C42A\r
22         for <notmuch@notmuchmail.org>; Fri,  6 Jun 2014 05:36:26 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1WstNc-00055E-Pi; Fri, 06 Jun 2014 13:36:24 +0100\r
27 Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1WstNc-00049S-A0; Fri, 06 Jun 2014 13:36:20 +0100\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH] lib: resurrect support for single-message mbox files\r
34 In-Reply-To: <1401950049-22351-1-git-send-email-jani@nikula.org>\r
35 References: <1401950049-22351-1-git-send-email-jani@nikula.org>\r
36 User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1\r
37         (x86_64-pc-linux-gnu)\r
38 Date: Fri, 06 Jun 2014 13:36:17 +0100\r
39 Message-ID: <8738fifc5a.fsf@qmul.ac.uk>\r
40 MIME-Version: 1.0\r
41 Content-Type: text/plain; charset=us-ascii\r
42 X-Sender-Host-Address: 87.81.223.162\r
43 X-QM-Geographic: According to ripencc,\r
44         this message was delivered by a machine in Britain (UK) (GB).\r
45 X-QM-SPAM-Info: Sender has good ham record.  :)\r
46 X-QM-Body-MD5: 402f53dcbeacc0cd03e2268770cf55c1 (of first 20000 bytes)\r
47 X-SpamAssassin-Score: -0.1\r
48 X-SpamAssassin-SpamBar: /\r
49 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
50         determine if it is\r
51         spam. We require at least 5.0 points to mark a message as spam.\r
52         This message scored -0.1 points.\r
53         Summary of the scoring: \r
54         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
55         provider *      (markwalters1009[at]gmail.com)\r
56         * -0.1 AWL AWL: From: address is in the auto white-list\r
57 X-QM-Scan-Virus: ClamAV says the message is clean\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Fri, 06 Jun 2014 12:36:34 -0000\r
71 \r
72 \r
73 On Thu, 05 Jun 2014, Jani Nikula <jani@nikula.org> wrote:\r
74 > This is effectively a revert of\r
75 >\r
76 > commit 6812136bf576d894591606d9e10096719054d1f9\r
77 > Author: Jani Nikula <jani@nikula.org>\r
78 > Date:   Mon Mar 31 00:21:48 2014 +0300\r
79 >\r
80 >     lib: drop support for single-message mbox files\r
81 >\r
82 > The intention was to drop support for indexing new single-message mbox\r
83 > files (and whether that was a good idea in the first place is\r
84 > arguable). However this inadvertently broke support for reading\r
85 > headers from previously indexed single-message mbox files, which is\r
86 > far worse.\r
87 >\r
88 > Distinguishing between the two cases would require more code than\r
89 > simply bringing back support for single-message mbox files.\r
90 \r
91 This LGTM +1.\r
92 \r
93 Best wishes\r
94 \r
95 Mark\r
96 \r
97 > ---\r
98 >  lib/message-file.c |   30 +++++++++++++++++++++++++-----\r
99 >  test/T050-new.sh   |   26 ++++++++++++++++----------\r
100 >  2 files changed, 41 insertions(+), 15 deletions(-)\r
101 >\r
102 > diff --git a/lib/message-file.c b/lib/message-file.c\r
103 > index 6782882..483ba1e 100644\r
104 > --- a/lib/message-file.c\r
105 > +++ b/lib/message-file.c\r
106 > @@ -117,7 +117,7 @@ notmuch_message_file_close (notmuch_message_file_t *message)\r
107 >  }\r
108 >  \r
109 >  static notmuch_bool_t\r
110 > -is_mbox (FILE *file)\r
111 > +_is_mbox (FILE *file)\r
112 >  {\r
113 >      char from_buf[5];\r
114 >      notmuch_bool_t ret = FALSE;\r
115 > @@ -139,13 +139,12 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)\r
116 >      GMimeParser *parser;\r
117 >      notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;\r
118 >      static int initialized = 0;\r
119 > +    notmuch_bool_t is_mbox;\r
120 >  \r
121 >      if (message->message)\r
122 >       return NOTMUCH_STATUS_SUCCESS;\r
123 >  \r
124 > -    /* We no longer support mboxes at all. */\r
125 > -    if (is_mbox (message->file))\r
126 > -     return NOTMUCH_STATUS_FILE_NOT_EMAIL;\r
127 > +    is_mbox = _is_mbox (message->file);\r
128 >  \r
129 >      if (! initialized) {\r
130 >       g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS);\r
131 > @@ -163,7 +162,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)\r
132 >      g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), FALSE);\r
133 >  \r
134 >      parser = g_mime_parser_new_with_stream (stream);\r
135 > -    g_mime_parser_set_scan_from (parser, FALSE);\r
136 > +    g_mime_parser_set_scan_from (parser, is_mbox);\r
137 >  \r
138 >      message->message = g_mime_parser_construct_message (parser);\r
139 >      if (! message->message) {\r
140 > @@ -171,6 +170,27 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)\r
141 >       goto DONE;\r
142 >      }\r
143 >  \r
144 > +    if (is_mbox) {\r
145 > +     if (! g_mime_parser_eos (parser)) {\r
146 > +         /* This is a multi-message mbox. */\r
147 > +         status = NOTMUCH_STATUS_FILE_NOT_EMAIL;\r
148 > +         goto DONE;\r
149 > +     }\r
150 > +     /*\r
151 > +      * For historical reasons, we support single-message mboxes,\r
152 > +      * but this behavior is likely to change in the future, so\r
153 > +      * warn.\r
154 > +      */\r
155 > +     static notmuch_bool_t mbox_warning = FALSE;\r
156 > +     if (! mbox_warning) {\r
157 > +         mbox_warning = TRUE;\r
158 > +         fprintf (stderr, "\\r
159 > +Warning: %s is an mbox containing a single message,\n\\r
160 > +likely caused by misconfigured mail delivery.  Support for single-message\n\\r
161 > +mboxes is deprecated and may be removed in the future.\n", message->filename);\r
162 > +     }\r
163 > +    }\r
164 > +\r
165 >    DONE:\r
166 >      g_object_unref (stream);\r
167 >      g_object_unref (parser);\r
168 > diff --git a/test/T050-new.sh b/test/T050-new.sh\r
169 > index 3c31954..ad46ee6 100755\r
170 > --- a/test/T050-new.sh\r
171 > +++ b/test/T050-new.sh\r
172 > @@ -163,6 +163,22 @@ rm -rf "${MAIL_DIR}"/two\r
173 >  output=$(NOTMUCH_NEW)\r
174 >  test_expect_equal "$output" "No new mail. Removed 3 messages."\r
175 >  \r
176 > +test_begin_subtest "Support single-message mbox (deprecated)"\r
177 > +cat > "${MAIL_DIR}"/mbox_file1 <<EOF\r
178 > +From test_suite@notmuchmail.org Fri Jan  5 15:43:57 2001\r
179 > +From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
180 > +To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
181 > +Subject: Test mbox message 1\r
182 > +\r
183 > +Body.\r
184 > +EOF\r
185 > +output=$(NOTMUCH_NEW 2>&1)\r
186 > +test_expect_equal "$output" \\r
187 > +"Warning: ${MAIL_DIR}/mbox_file1 is an mbox containing a single message,\r
188 > +likely caused by misconfigured mail delivery.  Support for single-message\r
189 > +mboxes is deprecated and may be removed in the future.\r
190 > +Added 1 new message to the database."\r
191 > +\r
192 >  # This test requires that notmuch new has been run at least once.\r
193 >  test_begin_subtest "Skip and report non-mail files"\r
194 >  generate_message\r
195 > @@ -184,24 +200,14 @@ Subject: Test mbox message 2\r
196 >  \r
197 >  Body 2.\r
198 >  EOF\r
199 > -cat > "${MAIL_DIR}"/mbox_file1 <<EOF\r
200 > -From test_suite@notmuchmail.org Fri Jan  5 15:43:57 2001\r
201 > -From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
202 > -To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
203 > -Subject: Test mbox message 1\r
204 > -\r
205 > -Body.\r
206 > -EOF\r
207 >  output=$(NOTMUCH_NEW 2>&1)\r
208 >  test_expect_equal "$output" \\r
209 >  "Note: Ignoring non-mail file: ${MAIL_DIR}/.git/config\r
210 >  Note: Ignoring non-mail file: ${MAIL_DIR}/.ignored_hidden_file\r
211 >  Note: Ignoring non-mail file: ${MAIL_DIR}/ignored_file\r
212 >  Note: Ignoring non-mail file: ${MAIL_DIR}/mbox_file\r
213 > -Note: Ignoring non-mail file: ${MAIL_DIR}/mbox_file1\r
214 >  Added 1 new message to the database."\r
215 >  rm "${MAIL_DIR}"/mbox_file\r
216 > -rm "${MAIL_DIR}"/mbox_file1\r
217 >  \r
218 >  test_begin_subtest "Ignore files and directories specified in new.ignore"\r
219 >  generate_message\r
220 > -- \r
221 > 1.7.2.5\r
222 >\r
223 > _______________________________________________\r
224 > notmuch mailing list\r
225 > notmuch@notmuchmail.org\r
226 > http://notmuchmail.org/mailman/listinfo/notmuch\r