X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fdatabase.cc;h=9c777156ab6292beb9066a1e097637021d1e9007;hb=f3c1eebfaf8526129ae6946cbcd44a3c602563d6;hp=289e41c45bb4d8607fa0c1b31e31fa355bd21d40;hpb=8bef9ba9220956beb8ff634c16344fb00689b973;p=notmuch diff --git a/lib/database.cc b/lib/database.cc index 289e41c4..9c777156 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -89,8 +89,9 @@ typedef struct { * * In addition, terms from the content of the message are added with * "from", "to", "attachment", and "subject" prefixes for use by the - * user in searching. But the database doesn't really care itself - * about any of these. + * user in searching. Similarly, terms from the path of the mail + * message are added with a "folder" prefix. But the database doesn't + * really care itself about any of these. * * The data portion of a mail document is empty. * @@ -204,7 +205,8 @@ static prefix_t PROBABILISTIC_PREFIX[]= { { "from", "XFROM" }, { "to", "XTO" }, { "attachment", "XATTACHMENT" }, - { "subject", "XSUBJECT"} + { "subject", "XSUBJECT"}, + { "folder", "XFOLDER"} }; int @@ -1716,11 +1718,20 @@ notmuch_database_remove_message (notmuch_database_t *notmuch, for ( ; i != end; i++) { Xapian::TermIterator j; + notmuch_message_t *message; + notmuch_private_status_t private_status; - document = find_document_for_doc_id (notmuch, *i); + message = _notmuch_message_create (local, notmuch, + *i, &private_status); + if (message == NULL) + return COERCE_STATUS (private_status, + "Inconsistent document ID in datbase."); - document.remove_term (term); + _notmuch_message_remove_filename (message, filename); + _notmuch_message_sync (message); + /* Take care to find document after sync'ing filename removal. */ + document = find_document_for_doc_id (notmuch, *i); j = document.termlist_begin (); j.skip_to (prefix); @@ -1731,7 +1742,6 @@ notmuch_database_remove_message (notmuch_database_t *notmuch, db->delete_document (document.get_docid ()); status = NOTMUCH_STATUS_SUCCESS; } else { - db->replace_document (document.get_docid (), document); status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID; } } @@ -1752,15 +1762,15 @@ _notmuch_convert_tags (void *ctx, Xapian::TermIterator &i, Xapian::TermIterator &end) { const char *prefix = _find_prefix ("tag"); - notmuch_tags_t *tags; + notmuch_string_list_t *list; std::string tag; /* Currently this iteration is written with the assumption that * "tag" has a single-character prefix. */ assert (strlen (prefix) == 1); - tags = _notmuch_tags_create (ctx); - if (unlikely (tags == NULL)) + list = _notmuch_string_list_create (ctx); + if (unlikely (list == NULL)) return NULL; i.skip_to (prefix); @@ -1771,14 +1781,14 @@ _notmuch_convert_tags (void *ctx, Xapian::TermIterator &i, if (tag.empty () || tag[0] != *prefix) break; - _notmuch_tags_add_tag (tags, tag.c_str () + 1); + _notmuch_string_list_append (list, tag.c_str () + 1); i++; } - _notmuch_tags_prepare_iterator (tags); + _notmuch_string_list_sort (list); - return tags; + return _notmuch_tags_create (ctx, list); } notmuch_tags_t *