X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;ds=sidebyside;f=database.cc;h=4524016b37aecb1d0ffbacfbe72d4b5c8b03b94d;hb=97ef8a74c93fc24a65d97ae621f482450503db09;hp=d7cd26c7656d2fd6fb85464d8c1c582d96ee11af;hpb=cfa228a3d4b300df3551e811028508d3de5cd81c;p=notmuch diff --git a/database.cc b/database.cc index d7cd26c7..4524016b 100644 --- a/database.cc +++ b/database.cc @@ -84,7 +84,7 @@ typedef struct { * * and has a single value: * - * TIMETAMPS: The time_t value from the user. + * TIMESTAMP: The time_t value from the user. */ /* With these prefix values we follow the conventions published here: @@ -105,6 +105,7 @@ typedef struct { prefix_t BOOLEAN_PREFIX_INTERNAL[] = { { "type", "T" }, { "ref", "XREFERENCE" }, + { "replyto", "XREPLYTO" }, { "timestamp", "XTIMESTAMP" }, { "contact", "XCONTACT" } }; @@ -487,6 +488,9 @@ notmuch_database_open (const char *path) notmuch = talloc (NULL, notmuch_database_t); notmuch->path = talloc_strdup (notmuch, path); + if (notmuch->path[strlen (notmuch->path) - 1] == '/') + notmuch->path[strlen (notmuch->path) - 1] = '\0'; + try { notmuch->xapian_db = new Xapian::WritableDatabase (xapian_path, Xapian::DB_CREATE_OR_OPEN); @@ -729,6 +733,8 @@ _notmuch_database_link_message_to_parents (notmuch_database_t *notmuch, in_reply_to = notmuch_message_file_get_header (message_file, "in-reply-to"); parse_references (message, parents, in_reply_to); + _notmuch_message_add_term (message, "replyto", + parse_message_id (message, in_reply_to, NULL)); keys = g_hash_table_get_keys (parents); for (l = keys; l; l = l->next) { @@ -854,11 +860,12 @@ notmuch_database_add_message (notmuch_database_t *notmuch, notmuch_message_t **message_ret) { notmuch_message_file_t *message_file; - notmuch_message_t *message; + notmuch_message_t *message = NULL; notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS; + notmuch_private_status_t private_status; const char *date, *header; - const char *from, *to, *subject, *old_filename; + const char *from, *to, *subject; char *message_id; if (message_ret) @@ -932,21 +939,20 @@ notmuch_database_add_message (notmuch_database_t *notmuch, message = _notmuch_message_create_for_message_id (NULL, notmuch, message_id, - &ret); + &private_status); talloc_free (message_id); if (message == NULL) goto DONE; - /* Has a message previously been added with the same ID? */ - old_filename = notmuch_message_get_filename (message); - if (old_filename && strlen (old_filename)) { - ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID; - goto DONE; - } else { + /* Is this a newly created message object? */ + if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) { _notmuch_message_set_filename (message, filename); _notmuch_message_add_term (message, "type", "mail"); + } else { + ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID; + goto DONE; } ret = _notmuch_database_link_message (notmuch, message, message_file);