X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fdatabase.cc;h=d88b168b9c872f31f9bf51ae5e6f537feccd1dbb;hb=f14d4c55ce95edacd4c04318f1d729fef0207aec;hp=293d21aa01ff70c03ecdcbe3221c92dca21247f5;hpb=d9d3d3e6f06a76dc0fbe24c9655b64acfcd4b9e4;p=notmuch diff --git a/lib/database.cc b/lib/database.cc index 293d21aa..d88b168b 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 @@ -688,8 +690,6 @@ notmuch_database_open (const char *path, notmuch = NULL; } - notmuch_database_set_maildir_sync (notmuch, FALSE); - DONE: if (notmuch_path) free (notmuch_path); @@ -719,13 +719,6 @@ 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) { @@ -1651,13 +1644,6 @@ 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"); @@ -1726,17 +1712,26 @@ notmuch_database_remove_message (notmuch_database_t *notmuch, if (status) return status; - term = talloc_asprintf (notmuch, "%s%s", prefix, direntry); + term = talloc_asprintf (local, "%s%s", prefix, direntry); find_doc_ids_for_term (notmuch, term, &i, &end); 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); @@ -1747,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; } }