X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=database.cc;h=d7cd26c7656d2fd6fb85464d8c1c582d96ee11af;hp=583bee82a2d3d95b81814002ac042489484a5122;hb=fbf55bfe2fdcdf3773ba37a9921875530e94c7b3;hpb=f9bbd7baa07110c7f345c8413e2426d00382cb1c diff --git a/database.cc b/database.cc index 583bee82..d7cd26c7 100644 --- a/database.cc +++ b/database.cc @@ -106,6 +106,7 @@ prefix_t BOOLEAN_PREFIX_INTERNAL[] = { { "type", "T" }, { "ref", "XREFERENCE" }, { "timestamp", "XTIMESTAMP" }, + { "contact", "XCONTACT" } }; prefix_t BOOLEAN_PREFIX_EXTERNAL[] = { @@ -128,6 +129,7 @@ _internal_error (const char *format, ...) va_start (va_args, format); + fprintf (stderr, "Internal error: "); vfprintf (stderr, format, va_args); exit (1); @@ -879,7 +881,25 @@ notmuch_database_add_message (notmuch_database_t *notmuch, (char *) NULL); try { - /* The first order of business is to find/create a message ID. */ + /* Before we do any real work, (especially before doing a + * potential SHA-1 computation on the entire file's contents), + * let's make sure that what we're looking at looks like an + * actual email message. + */ + from = notmuch_message_file_get_header (message_file, "from"); + subject = notmuch_message_file_get_header (message_file, "subject"); + to = notmuch_message_file_get_header (message_file, "to"); + + if (from == NULL && + subject == NULL && + to == NULL) + { + ret = NOTMUCH_STATUS_FILE_NOT_EMAIL; + goto DONE; + } + + /* Now that we're sure it's mail, the first order of business + * is to find a message ID (or else create one ourselves). */ header = notmuch_message_file_get_header (message_file, "message-id"); if (header) { @@ -936,18 +956,6 @@ notmuch_database_add_message (notmuch_database_t *notmuch, date = notmuch_message_file_get_header (message_file, "date"); _notmuch_message_set_date (message, date); - from = notmuch_message_file_get_header (message_file, "from"); - subject = notmuch_message_file_get_header (message_file, "subject"); - to = notmuch_message_file_get_header (message_file, "to"); - - if (from == NULL && - subject == NULL && - to == NULL) - { - ret = NOTMUCH_STATUS_FILE_NOT_EMAIL; - goto DONE; - } - _notmuch_message_index_file (message, filename); _notmuch_message_sync (message);