]> git.notmuchmail.org Git - notmuch/commitdiff
Protect against missing message id while indexing files
authorKeith Packard <keithp@keithp.com>
Thu, 15 Oct 2009 04:46:54 +0000 (21:46 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 15 Oct 2009 04:46:54 +0000 (21:46 -0700)
Makefile
notmuch-index-message.cc

index bf3a5200ff74b99e47c94e0b674c762c3294b2e1..17f29fb1960c202e00c56d70d1b65586340a5ed5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 PROGS=notmuch-index-message xapian-dump
 
-MYCXXFLAGS=-Wall
+MYCXXFLAGS=-Wall -O0 -g
 
 all: $(PROGS)
 
index 02f250b419f01dd5d643f4f8d98d61fa13531567..f16bd1adef052426732cc9a920c1d9325c2d4584 100644 (file)
@@ -662,8 +662,10 @@ index_file (Xapian::WritableDatabase db,
     add_term (doc, "type", "mail");
     add_term (doc, "source_id", "1");
 
-    add_term (doc, "msgid", message_id);
-    doc.add_value (NOTMUCH_VALUE_MESSAGE_ID, message_id);
+    if (message_id) {
+       add_term (doc, "msgid", message_id);
+       doc.add_value (NOTMUCH_VALUE_MESSAGE_ID, message_id);
+    }
 
     if (thread_ids->len) {
        unsigned int i;
@@ -687,7 +689,7 @@ index_file (Xapian::WritableDatabase db,
        doc.add_value (NOTMUCH_VALUE_THREAD, thread_id->str);
 
        g_string_free (thread_id, TRUE);
-    } else {
+    } else if (message_id) {
        /* If not referenced thread, use the message ID */
        add_term (doc, "thread", message_id);
        doc.add_value (NOTMUCH_VALUE_THREAD, message_id);