X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdatabase.cc;h=cf87d08d06c42cd0b41dfa1ba06d1c504b337ba7;hp=92c3c4e0a7f03088f9a8337233fc35056605e9fc;hb=bfe4555325086d5cb99e3962424128f94d1c921d;hpb=e4379c43e21ff69dcdb66064fe3de83ae0642fc0 diff --git a/lib/database.cc b/lib/database.cc index 92c3c4e0..cf87d08d 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -1747,7 +1747,6 @@ notmuch_status_t notmuch_database_remove_message (notmuch_database_t *notmuch, const char *filename) { - Xapian::WritableDatabase *db; void *local; const char *prefix = _find_prefix ("file-direntry"); char *direntry, *term; @@ -1761,8 +1760,6 @@ notmuch_database_remove_message (notmuch_database_t *notmuch, local = talloc_new (notmuch); - db = static_cast (notmuch->xapian_db); - try { status = _notmuch_database_filename_to_direntry (local, notmuch, @@ -1785,23 +1782,11 @@ notmuch_database_remove_message (notmuch_database_t *notmuch, return COERCE_STATUS (private_status, "Inconsistent document ID in datbase."); - _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); - - /* Was this the last file-direntry in the message? */ - if (j == document.termlist_end () || - strncmp ((*j).c_str (), prefix, strlen (prefix))) - { - db->delete_document (document.get_docid ()); - status = NOTMUCH_STATUS_SUCCESS; - } else { - status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID; - } + status = _notmuch_message_remove_filename (message, filename); + if (status == NOTMUCH_STATUS_SUCCESS) + _notmuch_message_delete (message); + else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) + _notmuch_message_sync (message); } } catch (const Xapian::Error &error) { fprintf (stderr, "Error: A Xapian exception occurred removing message: %s\n",