[PATCH 04/10] lib: Make _notmuch_message_sync capable of deleting a message.

Austin Clements amdragon at MIT.EDU
Thu Feb 17 23:58:54 PST 2011


---
 lib/message.cc |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index 0590f76..06747fe 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -29,6 +29,7 @@ struct _notmuch_message {
     notmuch_database_t *notmuch;
     Xapian::docid doc_id;
     int frozen;
+    notmuch_bool_t deleted;
     char *message_id;
     char *thread_id;
     char *in_reply_to;
@@ -96,6 +97,7 @@ _notmuch_message_create_for_document (const void *talloc_owner,
     message->doc_id = doc_id;
 
     message->frozen = 0;
+    message->deleted = FALSE;
     message->flags = 0;
 
     /* Each of these will be lazily created as needed. */
@@ -765,7 +767,10 @@ _notmuch_message_sync (notmuch_message_t *message)
 	return;
 
     db = static_cast <Xapian::WritableDatabase *> (message->notmuch->xapian_db);
-    db->replace_document (message->doc_id, message->doc);
+    if (message->deleted)
+	db->delete_document (message->doc_id);
+    else
+	db->replace_document (message->doc_id, message->doc);
 }
 
 /* Ensure that 'message' is not holding any file object open. Future
-- 
1.7.2.3



More information about the notmuch mailing list