X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fmessage.cc;h=26b5e76e9636b67e43ca5c42c08210f73c70f0c2;hp=1ddce3c692bebdc94fa22023a7b80d05345d69c4;hb=7f57b747b95eece465d10fd0acba20cc3dd868f1;hpb=c9e1c4f1c495d7cc24a64b73edb4b7b71791a87f diff --git a/lib/message.cc b/lib/message.cc index 1ddce3c6..26b5e76e 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -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;