From: David Bremner <brem...@unb.ca> This might not be ideal from the point of view of "atomic" transactions, but it is transparent to the caller of the library. --- lib/message.cc | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/lib/message.cc b/lib/message.cc index 71f5619..0385e68 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -600,12 +600,17 @@ void _notmuch_message_sync (notmuch_message_t *message) { Xapian::WritableDatabase *db; + notmuch_log_t *log; if (message->notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY) return; db = static_cast <Xapian::WritableDatabase *> (message->notmuch->xapian_db); db->replace_document (message->doc_id, message->doc); + + log = notmuch_database_get_log(message->notmuch); + if (log) + notmuch_log_sync (log); } /* Ensure that 'message' is not holding any file object open. Future @@ -635,10 +640,16 @@ _notmuch_message_add_term (notmuch_message_t *message, { char *term; + notmuch_log_t *log; if (value == NULL) return NOTMUCH_PRIVATE_STATUS_NULL_POINTER; + log=notmuch_database_get_log(message->notmuch); + if (log) + notmuch_log_words (log,"+", prefix_name, value, + notmuch_message_get_message_id (message), NULL); + term = talloc_asprintf (message, "%s%s", _find_prefix (prefix_name), value); @@ -691,10 +702,16 @@ _notmuch_message_remove_term (notmuch_message_t *message, const char *value) { char *term; + notmuch_log_t *log; if (value == NULL) return NOTMUCH_PRIVATE_STATUS_NULL_POINTER; + log=notmuch_database_get_log(message->notmuch); + if (log) + notmuch_log_words (log,"-", prefix_name, value, + notmuch_message_get_message_id (message), NULL); + term = talloc_asprintf (message, "%s%s", _find_prefix (prefix_name), value); @@ -806,6 +823,7 @@ notmuch_status_t notmuch_message_freeze (notmuch_message_t *message) { notmuch_status_t status; + notmuch_log_t* log; status = _notmuch_database_ensure_writable (message->notmuch); if (status) @@ -813,6 +831,10 @@ notmuch_message_freeze (notmuch_message_t *message) message->frozen++; + log = notmuch_database_get_log (message->notmuch); + if (log) + notmuch_log_start_transaction (log); + return NOTMUCH_STATUS_SUCCESS; } @@ -820,6 +842,7 @@ notmuch_status_t notmuch_message_thaw (notmuch_message_t *message) { notmuch_status_t status; + notmuch_log_t* log; status = _notmuch_database_ensure_writable (message->notmuch); if (status) @@ -827,12 +850,19 @@ notmuch_message_thaw (notmuch_message_t *message) if (message->frozen > 0) { message->frozen--; + + log = notmuch_database_get_log (message->notmuch); + if (log) + notmuch_log_finish_transaction (log); + if (message->frozen == 0) _notmuch_message_sync (message); + return NOTMUCH_STATUS_SUCCESS; } else { return NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW; } + } void -- 1.7.1 _______________________________________________ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch