X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fmessage.cc;h=5ccca95a2a928d1e7fd3322a17871c7574cbfe35;hb=1d5d0ae68689e7b1d6b974e275f19371250c4b25;hp=e2069123db4f6547dfc4cde955300088fd15b9c5;hpb=879ec9d76ad5caeb728c3f047d1da425d0b511eb;p=notmuch diff --git a/lib/message.cc b/lib/message.cc index e2069123..5ccca95a 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -1383,21 +1383,21 @@ _notmuch_message_delete (notmuch_message_t *message) if (status) return status; - message->notmuch->writable_xapian_db->delete_document (message->doc_id); - - /* if this was a ghost to begin with, we are done */ - private_status = _notmuch_message_has_term (message, "type", "ghost", &is_ghost); - if (private_status) - return COERCE_STATUS (private_status, - "Error trying to determine whether message was a ghost"); - if (is_ghost) - return NOTMUCH_STATUS_SUCCESS; - - /* look for a non-ghost message in the same thread */ try { Xapian::PostingIterator thread_doc, thread_doc_end; Xapian::PostingIterator mail_doc, mail_doc_end; + message->notmuch->writable_xapian_db->delete_document (message->doc_id); + + /* look for a non-ghost message in the same thread */ + /* if this was a ghost to begin with, we are done */ + private_status = _notmuch_message_has_term (message, "type", "ghost", &is_ghost); + if (private_status) + return COERCE_STATUS (private_status, + "Error trying to determine whether message was a ghost"); + if (is_ghost) + return NOTMUCH_STATUS_SUCCESS; + _notmuch_database_find_doc_ids (message->notmuch, "thread", tid, &thread_doc, &thread_doc_end); _notmuch_database_find_doc_ids (message->notmuch, "type", "mail", &mail_doc, &mail_doc_end); @@ -2039,6 +2039,10 @@ notmuch_message_tags_to_maildir_flags (notmuch_message_t *message) char *to_set, *to_clear; notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; + status = _notmuch_database_ensure_writable (message->notmuch); + if (status) + return status; + _get_maildir_flag_actions (message, &to_set, &to_clear); for (filenames = notmuch_message_get_filenames (message);