unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Don't bother checking for mbox files
@ 2016-03-10  0:08 Keith Packard
  2016-03-13 10:57 ` Edward Betts
  0 siblings, 1 reply; 4+ messages in thread
From: Keith Packard @ 2016-03-10  0:08 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 2792 bytes --]


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 <keithp@keithp.com>
---
 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
--- a/lib/message-file.c
+++ b/lib/message-file.c
@@ -98,22 +98,6 @@ _notmuch_message_file_close (notmuch_message_file_t *message)
     talloc_free (message);
 }
 
-static notmuch_bool_t
-_is_mbox (FILE *file)
-{
-    char from_buf[5];
-    notmuch_bool_t ret = FALSE;
-
-    /* Is this mbox? */
-    if (fread (from_buf, sizeof (from_buf), 1, file) == 1 &&
-	strncmp (from_buf, "From ", 5) == 0)
-	ret = TRUE;
-
-    rewind (file);
-
-    return ret;
-}
-
 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 = NOTMUCH_STATUS_SUCCESS;
     static int initialized = 0;
-    notmuch_bool_t is_mbox;
 
     if (message->message)
 	return NOTMUCH_STATUS_SUCCESS;
 
-    is_mbox = _is_mbox (message->file);
-
     if (! initialized) {
 	g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS);
 	initialized = 1;
@@ -144,7 +125,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
     g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), FALSE);
 
     parser = g_mime_parser_new_with_stream (stream);
-    g_mime_parser_set_scan_from (parser, is_mbox);
+    g_mime_parser_set_scan_from (parser, FALSE);
 
     message->message = g_mime_parser_construct_message (parser);
     if (! message->message) {
@@ -152,14 +133,6 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
 	goto DONE;
     }
 
-    if (is_mbox && ! g_mime_parser_eos (parser)) {
-	/*
-	 * This is a multi-message mbox. (For historical reasons, we
-	 * do support single-message mboxes.)
-	 */
-	status = NOTMUCH_STATUS_FILE_NOT_EMAIL;
-    }
-
   DONE:
     g_object_unref (stream);
     g_object_unref (parser);
-- 
2.7.0


-- 
-keith

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 810 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-14  7:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-10  0:08 [PATCH] Don't bother checking for mbox files Keith Packard
2016-03-13 10:57 ` Edward Betts
2016-03-13 12:48   ` Jani Nikula
2016-03-14  7:23     ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).