aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/database.cc
diff options
context:
space:
mode:
authorGravatar Jani Nikula <jani@nikula.org>2014-03-31 00:21:49 +0300
committerGravatar David Bremner <david@tethera.net>2014-04-05 12:53:04 -0300
commit473930bb6fb167078a9428ad85f53accf7d4559f (patch)
tree4cdf734de80569e918ff29116a0419f2ab66f4b4 /lib/database.cc
parent6812136bf576d894591606d9e10096719054d1f9 (diff)
lib: replace the header parser with gmime
The notmuch library includes a full blown message header parser. Yet the same message headers are parsed by gmime during indexing. Switch to gmime parsing completely. These are the main changes: * Gmime stops header parsing at the first invalid header, and presumes the message body starts from there. The current parser is quite liberal in accepting broken headers. The change means we will be much pickier about accepting invalid messages. * The current parser converts tabs used in header folding to spaces. Gmime preserve the tabs. Due to a broken python library used in mailman, there are plenty of mailing lists that produce headers with tabs in header folding, and we'll see plenty of tabs. (This change has been mitigated in preparatory patches.) * For pure header parsing, the current parser is likely faster than gmime, which parses the whole message rather than just the headers. Since we parse the message and its headers using gmime for indexing anyway, this avoids and extra header parsing round when adding new messages. In case of duplicate messages, we'll end up parsing the full message although just headers would be sufficient. All in all this should still speed up 'notmuch new'. * Calls to notmuch_message_get_header() may be slightly slower than previously for headers that are not indexed in the database, due to parsing of the whole message. Within the notmuch code base, notmuch reply is the only such user.
Diffstat (limited to 'lib/database.cc')
-rw-r--r--lib/database.cc15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/database.cc b/lib/database.cc
index aef748f7..1efb14d4 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1971,15 +1971,10 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
if (ret)
goto DONE;
- notmuch_message_file_restrict_headers (message_file,
- "date",
- "from",
- "in-reply-to",
- "message-id",
- "references",
- "subject",
- "to",
- (char *) NULL);
+ /* Parse message up front to get better error status. */
+ ret = _notmuch_message_file_parse (message_file);
+ if (ret)
+ goto DONE;
try {
/* Before we do any real work, (especially before doing a
@@ -2066,7 +2061,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
date = notmuch_message_file_get_header (message_file, "date");
_notmuch_message_set_header_values (message, date, from, subject);
- ret = _notmuch_message_index_file (message, filename);
+ ret = _notmuch_message_index_file (message, message_file);
if (ret)
goto DONE;
} else {