From: Keith Packard Date: Thu, 10 Mar 2016 00:08:17 +0000 (+1600) Subject: [PATCH] Don't bother checking for mbox files X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fa0007b4e169022b70956ff2c2098530ea750cec;p=notmuch-archives.git [PATCH] Don't bother checking for mbox files --- diff --git a/b9/e0bcf8ff5f89b567282243914ff30df31ec42f b/b9/e0bcf8ff5f89b567282243914ff30df31ec42f new file mode 100644 index 000000000..279fce9a4 --- /dev/null +++ b/b9/e0bcf8ff5f89b567282243914ff30df31ec42f @@ -0,0 +1,182 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 1BB756DE0B64 + for ; Wed, 9 Mar 2016 16:16:57 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.442 +X-Spam-Level: +X-Spam-Status: No, score=-0.442 tagged_above=-999 required=5 + tests=[AWL=-0.432, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 8RyBEcGoNBBu for ; + Wed, 9 Mar 2016 16:16:54 -0800 (PST) +X-Greylist: delayed 514 seconds by postgrey-1.35 at arlo; + Wed, 09 Mar 2016 16:16:54 PST +Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) + by arlo.cworth.org (Postfix) with ESMTP id 4D47C6DE005F + for ; Wed, 9 Mar 2016 16:16:54 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by elaine.keithp.com (Postfix) with ESMTP id 4AA7E3F20552 + for ; Wed, 9 Mar 2016 16:08:19 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at keithp.com +Received: from elaine.keithp.com ([127.0.0.1]) + by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 2ch7IRecElz3 for ; + Wed, 9 Mar 2016 16:08:18 -0800 (PST) +Received: by elaine.keithp.com (Postfix, from userid 1033) + id 815513F207E4; Wed, 9 Mar 2016 16:08:18 -0800 (PST) +Received: from hiro.keithp.com (localhost [127.0.0.1]) + by elaine.keithp.com (Postfix) with ESMTP id 6523D3F20552 + for ; Wed, 9 Mar 2016 16:08:18 -0800 (PST) +Received: by hiro.keithp.com (Postfix, from userid 1001) + id 452C37414B5; Wed, 9 Mar 2016 18:08:18 -0600 (CST) +From: "Keith Packard" +To: notmuch@notmuchmail.org +Subject: [PATCH] Don't bother checking for mbox files +User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 + (x86_64-pc-linux-gnu) +Date: Wed, 09 Mar 2016 16:08:17 -0800 +Message-ID: <86io0v9oum.fsf@hiro.keithp.com> +MIME-Version: 1.0 +Content-Type: multipart/signed; boundary="=-=-="; + micalg=pgp-sha256; protocol="application/pgp-signature" +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 10 Mar 2016 00:16:57 -0000 + +--=-=-= +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + + +Postfix adds mbox-style From lines when used in combination with +maildrop or .forward files. If they have another line starting with +'From ' in them, notmuch complains about them not being mail files. + +If we assume the user hasn't screwed up and misconfigured their mail +system, then we can safely ignore whether the file started with an +mbox header and just parse it as a single-message file. + +I can't see any harm in doing this; in the worst case, you'll have a +single 'message' which contains multiple emails now, while the +alternative is to miss mail entirely. + +I could be convinced to add a config option to enable this behaviour, +but I'd really rather not. + +Signed-off-by: Keith Packard +=2D-- + lib/message-file.c | 29 +---------------------------- + 1 file changed, 1 insertion(+), 28 deletions(-) + +diff --git a/lib/message-file.c b/lib/message-file.c +index ee30520..f03e1db 100644 +=2D-- a/lib/message-file.c ++++ b/lib/message-file.c +@@ -98,22 +98,6 @@ _notmuch_message_file_close (notmuch_message_file_t *mes= +sage) + talloc_free (message); + } +=20 +=2Dstatic notmuch_bool_t +=2D_is_mbox (FILE *file) +=2D{ +=2D char from_buf[5]; +=2D notmuch_bool_t ret =3D FALSE; +=2D +=2D /* Is this mbox? */ +=2D if (fread (from_buf, sizeof (from_buf), 1, file) =3D=3D 1 && +=2D strncmp (from_buf, "From ", 5) =3D=3D 0) +=2D ret =3D TRUE; +=2D +=2D rewind (file); +=2D +=2D return ret; +=2D} +=2D + notmuch_status_t + _notmuch_message_file_parse (notmuch_message_file_t *message) + { +@@ -121,13 +105,10 @@ _notmuch_message_file_parse (notmuch_message_file_t *= +message) + GMimeParser *parser; + notmuch_status_t status =3D NOTMUCH_STATUS_SUCCESS; + static int initialized =3D 0; +=2D notmuch_bool_t is_mbox; +=20 + if (message->message) + return NOTMUCH_STATUS_SUCCESS; +=20 +=2D is_mbox =3D _is_mbox (message->file); +=2D + if (! initialized) { + g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS); + initialized =3D 1; +@@ -144,7 +125,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *me= +ssage) + g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), FALSE); +=20 + parser =3D g_mime_parser_new_with_stream (stream); +=2D g_mime_parser_set_scan_from (parser, is_mbox); ++ g_mime_parser_set_scan_from (parser, FALSE); +=20 + message->message =3D g_mime_parser_construct_message (parser); + if (! message->message) { +@@ -152,14 +133,6 @@ _notmuch_message_file_parse (notmuch_message_file_t *m= +essage) + goto DONE; + } +=20 +=2D if (is_mbox && ! g_mime_parser_eos (parser)) { +=2D /* +=2D * This is a multi-message mbox. (For historical reasons, we +=2D * do support single-message mboxes.) +=2D */ +=2D status =3D NOTMUCH_STATUS_FILE_NOT_EMAIL; +=2D } +=2D + DONE: + g_object_unref (stream); + g_object_unref (parser); +=2D-=20 +2.7.0 + + +=2D-=20 +=2Dkeith + +--=-=-= +Content-Type: application/pgp-signature; name="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1 + +iQIVAwUBVuC68tsiGmkAAAARAQgs8A/9FPH/S8fAm+4eKV5WhbtdqJSOH1UV1oD1 +TgR/e68BoetNGXwsolvyTADYf/u6R/JxSAHQwkgRPvL/LbsG+gwrt+MCSFfburwW +rcJ7snYzpRhyvlone7wEGt2xlzuQGbZC43YSkL5npVupnKqgaoL/7x26ciF+u6Qq +OBz7CDGs530WGlgSyoQYfjLkVhY1S3zBL1+INfevK0DUIB+TZmh9bAppTxp3hewH +bF+YoZA/KaAzys0oNMHH7oMJRPYzLnKGjriqq/H2HUwKjZcf/VU+TFOcXL2RBoN4 +KxUf7O6/flhb6CY40iJuhzLVuX0geckVmRchbFnIYxKpYIaf26BWK7dWJTBZCvdK +bwPJzHhVapsnk9grRYbguJHxomqBVfPqrFZYYzIzLqEbAybqcWCuZ88cnzqTdHqd +Rhqg2xlUnBYqkp8DmTv+qiNSQ0h8V8Gq5MZ7LZ9g93NCMkfD0MaoslgYaDIIDCpG +Yu8jnqet+vdvMIYE936yfRUvSSy53qjFxAg90NlMgpjGm2TorD3Z66wfI5c2Oby+ +z3Tr0EHCEZYfRVbdZaFQBaSdFyUmuMB6HiL9s49Y9CkY/6ncJPqKwpNvA/WLPOow +RcP10f659lMCRVOVePTCsmXUKIhypKWGuXuge+wqnVfpCtAuvbb0FMD9vrF2sET7 +YYAJ5AWJAUE= +=hHCz +-----END PGP SIGNATURE----- +--=-=-=--