X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fmessage.cc;h=8d72ea22207b56b00cb600dfb3b68258374ba076;hp=1ddce3c692bebdc94fa22023a7b80d05345d69c4;hb=07b6220a5595bf4556e636709220121d6405e9e9;hpb=e6ad3a5dd4ca7a09a4760c4eb6721217cc906aaa diff --git a/lib/message.cc b/lib/message.cc index 1ddce3c6..8d72ea22 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -728,7 +728,7 @@ _notmuch_message_add_filename (notmuch_message_t *message, * Note: This function does not remove a document from the database, * even if the specified filename is the only filename for this * message. For that functionality, see - * _notmuch_database_remove_message. */ + * notmuch_database_remove_message. */ notmuch_status_t _notmuch_message_remove_filename (notmuch_message_t *message, const char *filename) @@ -998,6 +998,16 @@ _notmuch_message_set_header_values (notmuch_message_t *message, message->modified = TRUE; } +/* Upgrade a message to support NOTMUCH_FEATURE_LAST_MOD. The caller + * must call _notmuch_message_sync. */ +void +_notmuch_message_upgrade_last_mod (notmuch_message_t *message) +{ + /* _notmuch_message_sync will update the last modification + * revision; we just have to ask it to. */ + message->modified = TRUE; +} + /* Synchronize changes made to message->doc out into the database. */ void _notmuch_message_sync (notmuch_message_t *message) @@ -1010,6 +1020,18 @@ _notmuch_message_sync (notmuch_message_t *message) if (! message->modified) return; + /* Update the last modification of this message. */ + if (message->notmuch->features & NOTMUCH_FEATURE_LAST_MOD) + /* sortable_serialise gives a reasonably compact encoding, + * which directly translates to reduced IO when scanning the + * value stream. Since it's built for doubles, we only get 53 + * effective bits, but that's still enough for the database to + * last a few centuries at 1 million revisions per second. */ + message->doc.add_value (NOTMUCH_VALUE_LAST_MOD, + Xapian::sortable_serialise ( + _notmuch_database_new_revision ( + message->notmuch))); + db = static_cast (message->notmuch->xapian_db); db->replace_document (message->doc_id, message->doc); message->modified = FALSE; @@ -1158,7 +1180,7 @@ _notmuch_message_remove_term (notmuch_message_t *message, message->doc.remove_term (term); message->modified = TRUE; } catch (const Xapian::InvalidArgumentError) { - /* We'll let the philosopher's try to wrestle with the + /* We'll let the philosophers try to wrestle with the * question of whether failing to remove that which was not * there in the first place is failure. For us, we'll silently * consider it all good. */