X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=3974e2ed3a35c1278443095d452dbd1243b7fef2;hp=b673718223aa448bf22e7fb01101e20daa8eac7a;hb=08757767de5c148cea8e7b97274789f851fbd854;hpb=d1e8c80b7239705b05bfa3e129c5de1c7099498a diff --git a/lib/database.cc b/lib/database.cc index b6737182..3974e2ed 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -254,6 +254,7 @@ static prefix_t PROBABILISTIC_PREFIX[]= { { "from", "XFROM" }, { "to", "XTO" }, { "attachment", "XATTACHMENT" }, + { "mimetype", "XMIMETYPE"}, { "subject", "XSUBJECT"}, }; @@ -304,6 +305,11 @@ static const struct { "exact folder:/path: search", "rw" }, { NOTMUCH_FEATURE_GHOSTS, "mail documents for missing messages", "w"}, + /* Knowledge of the index mime-types are not required for reading + * a database because a reader will just be unable to query + * them. */ + { NOTMUCH_FEATURE_INDEXED_MIMETYPES, + "indexed MIME types", "w"}, }; const char * @@ -646,9 +652,10 @@ notmuch_database_create (const char *path, notmuch_database_t **database) if (status) goto DONE; - /* Upgrade doesn't add this feature to existing databases, but new - * databases have it. */ + /* Upgrade doesn't add these feature to existing databases, but + * new databases have them. */ notmuch->features |= NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES; + notmuch->features |= NOTMUCH_FEATURE_INDEXED_MIMETYPES; status = notmuch_database_upgrade (notmuch, NULL, NULL); if (status) { @@ -2136,11 +2143,11 @@ _consume_metadata_thread_id (void *ctx, notmuch_database_t *notmuch, * reference 'message'. * * In all cases, we assign to the current message the first thread ID - * found (through either parent or child). We will also merge any - * existing, distinct threads where this message belongs to both, - * (which is not uncommon when messages are processed out of order). + * found. We will also merge any existing, distinct threads where this + * message belongs to both, (which is not uncommon when messages are + * processed out of order). * - * Finally, if no thread ID has been found through parent or child, we + * Finally, if no thread ID has been found through referenced messages, we * call _notmuch_message_generate_thread_id to generate a new thread * ID. This should only happen for new, top-level messages, (no * References or In-Reply-To header in this message, and no previously @@ -2172,10 +2179,23 @@ _notmuch_database_link_message (notmuch_database_t *notmuch, if (status) goto DONE; - status = _notmuch_database_link_message_to_children (notmuch, message, - &thread_id); - if (status) - goto DONE; + if (! (notmuch->features & NOTMUCH_FEATURE_GHOSTS)) { + /* In general, it shouldn't be necessary to link children, + * since the earlier indexing of those children will have + * stored a thread ID for the missing parent. However, prior + * to ghost messages, these stored thread IDs were NOT + * rewritten during thread merging (and there was no + * performant way to do so), so if indexed children were + * pulled into a different thread ID by a merge, it was + * necessary to pull them *back* into the stored thread ID of + * the parent. With ghost messages, we just rewrite the + * stored thread IDs during merging, so this workaround isn't + * necessary. */ + status = _notmuch_database_link_message_to_children (notmuch, message, + &thread_id); + if (status) + goto DONE; + } /* If not part of any existing thread, generate a new thread ID. */ if (thread_id == NULL) {