[PATCH 4/4] lib/message.cc: use view number to invalidate cached metadata
David Bremner
david at tethera.net
Fri Feb 24 19:45:13 PST 2017
Currently the view number is incremented by notmuch_database_reopen
---
lib/message.cc | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/lib/message.cc b/lib/message.cc
index 15e2f528..bfb95917 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -317,11 +317,14 @@ _notmuch_message_get_term (notmuch_message_t *message,
}
static void
-_notmuch_message_ensure_metadata (notmuch_message_t *message)
+_notmuch_message_ensure_metadata (notmuch_message_t *message, void *field)
{
Xapian::TermIterator i, end;
notmuch_bool_t success = FALSE;
+ if ((field != NULL) && (message->last_view >= message->notmuch->view))
+ return;
+
const char *thread_prefix = _find_prefix ("thread"),
*tag_prefix = _find_prefix ("tag"),
*id_prefix = _find_prefix ("id"),
@@ -472,8 +475,7 @@ _notmuch_message_get_doc_id (notmuch_message_t *message)
const char *
notmuch_message_get_message_id (notmuch_message_t *message)
{
- if (!message->message_id)
- _notmuch_message_ensure_metadata (message);
+ _notmuch_message_ensure_metadata (message, message->message_id);
if (!message->message_id)
INTERNAL_ERROR ("Message with document ID of %u has no message ID.\n",
message->doc_id);
@@ -548,16 +550,14 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header)
const char *
_notmuch_message_get_in_reply_to (notmuch_message_t *message)
{
- if (!message->in_reply_to)
- _notmuch_message_ensure_metadata (message);
+ _notmuch_message_ensure_metadata (message, message->in_reply_to);
return message->in_reply_to;
}
const char *
notmuch_message_get_thread_id (notmuch_message_t *message)
{
- if (!message->thread_id)
- _notmuch_message_ensure_metadata (message);
+ _notmuch_message_ensure_metadata (message, message->thread_id);
if (!message->thread_id)
INTERNAL_ERROR ("Message with document ID of %u has no thread ID.\n",
message->doc_id);
@@ -860,8 +860,7 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message)
if (message->filename_list)
return;
- if (!message->filename_term_list)
- _notmuch_message_ensure_metadata (message);
+ _notmuch_message_ensure_metadata (message, message->filename_term_list);
message->filename_list = _notmuch_string_list_create (message);
node = message->filename_term_list->head;
@@ -955,7 +954,7 @@ notmuch_message_get_flag (notmuch_message_t *message,
{
if (flag == NOTMUCH_MESSAGE_FLAG_GHOST &&
! NOTMUCH_TEST_BIT (message->lazy_flags, flag))
- _notmuch_message_ensure_metadata (message);
+ _notmuch_message_ensure_metadata (message, NULL);
return NOTMUCH_TEST_BIT (message->flags, flag);
}
@@ -996,8 +995,7 @@ notmuch_message_get_tags (notmuch_message_t *message)
{
notmuch_tags_t *tags;
- if (!message->tag_list)
- _notmuch_message_ensure_metadata (message);
+ _notmuch_message_ensure_metadata (message, message->tag_list);
tags = _notmuch_tags_create (message, message->tag_list);
/* _notmuch_tags_create steals the reference to the tag_list, but
@@ -1833,8 +1831,7 @@ _notmuch_message_ensure_property_map (notmuch_message_t *message)
if (message->property_map)
return;
- if (!message->property_term_list)
- _notmuch_message_ensure_metadata (message);
+ _notmuch_message_ensure_metadata (message, message->property_term_list);
message->property_map = _notmuch_string_map_create (message);
--
2.11.0
More information about the notmuch
mailing list