From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 945D06DE1B8C for ; Fri, 24 Feb 2017 19:45:34 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FDVOTvo3HVy2 for ; Fri, 24 Feb 2017 19:45:33 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 7E2C16DE1B44 for ; Fri, 24 Feb 2017 19:45:33 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1chTHw-0005mO-IB; Fri, 24 Feb 2017 22:44:52 -0500 Received: (nullmailer pid 19513 invoked by uid 1000); Sat, 25 Feb 2017 03:45:28 -0000 From: David Bremner To: notmuch@notmuchmail.org, eg@gaute.vetsj.com Subject: [PATCH 4/4] lib/message.cc: use view number to invalidate cached metadata Date: Fri, 24 Feb 2017 23:45:13 -0400 Message-Id: <20170225034513.19427-5-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170225034513.19427-1-david@tethera.net> References: <20170225034513.19427-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Feb 2017 03:45:34 -0000 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