X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=293d21aa01ff70c03ecdcbe3221c92dca21247f5;hp=6affc205e4e81b894443722b30f54457ff7669e3;hb=d9d3d3e6f06a76dc0fbe24c9655b64acfcd4b9e4;hpb=7b78eb4af6e87532795d09bd82152002ab4a74b1 diff --git a/lib/database.cc b/lib/database.cc index 6affc205..293d21aa 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -24,7 +24,6 @@ #include #include -#include #include /* g_free, GPtrArray, GHashTable */ @@ -185,7 +184,7 @@ typedef struct { * nearly universal to all mail messages). */ -prefix_t BOOLEAN_PREFIX_INTERNAL[] = { +static prefix_t BOOLEAN_PREFIX_INTERNAL[] = { { "type", "T" }, { "reference", "XREFERENCE" }, { "replyto", "XREPLYTO" }, @@ -194,14 +193,14 @@ prefix_t BOOLEAN_PREFIX_INTERNAL[] = { { "directory-direntry", "XDDIRENTRY" }, }; -prefix_t BOOLEAN_PREFIX_EXTERNAL[] = { +static prefix_t BOOLEAN_PREFIX_EXTERNAL[] = { { "thread", "G" }, { "tag", "K" }, { "is", "K" }, { "id", "Q" } }; -prefix_t PROBABILISTIC_PREFIX[]= { +static prefix_t PROBABILISTIC_PREFIX[]= { { "from", "XFROM" }, { "to", "XTO" }, { "attachment", "XATTACHMENT" }, @@ -689,6 +688,8 @@ notmuch_database_open (const char *path, notmuch = NULL; } + notmuch_database_set_maildir_sync (notmuch, FALSE); + DONE: if (notmuch_path) free (notmuch_path); @@ -718,6 +719,13 @@ notmuch_database_close (notmuch_database_t *notmuch) talloc_free (notmuch); } +void +notmuch_database_set_maildir_sync (notmuch_database_t *database, + notmuch_bool_t maildir_sync) +{ + database->maildir_sync = maildir_sync; +} + const char * notmuch_database_get_path (notmuch_database_t *notmuch) { @@ -1300,7 +1308,7 @@ _resolve_message_id_to_thread_id (notmuch_database_t *notmuch, talloc_free (metadata_key); - return thread_id; + return talloc_strdup (ctx, thread_id); } static notmuch_status_t @@ -1643,6 +1651,13 @@ notmuch_database_add_message (notmuch_database_t *notmuch, _notmuch_message_add_filename (message, filename); + /* This is a new message or it has a new filename and as such, + * its tags in database either do not exists or might be out + * of date. We assign the tags later in notmuch new, but until + * then we should not synchronize the tags back to the maildir + * flags (if notmuch is configured to do so). */ + notmuch_message_set_flag(message, NOTMUCH_MESSAGE_FLAG_TAGS_INVALID, TRUE); + /* Is this a newly created message object? */ if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) { _notmuch_message_add_term (message, "type", "mail"); @@ -1671,7 +1686,8 @@ notmuch_database_add_message (notmuch_database_t *notmuch, DONE: if (message) { - if (ret == NOTMUCH_STATUS_SUCCESS && message_ret) + if ((ret == NOTMUCH_STATUS_SUCCESS || + ret == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) && message_ret) *message_ret = message; else notmuch_message_destroy (message);