unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: David Bremner <david@tethera.net>,
	notmuch@notmuchmail.org, eg@gaute.vetsj.com
Subject: Re: [PATCH 4/4] lib/message.cc: use view number to invalidate cached metadata
Date: Sat, 25 Feb 2017 20:44:31 +0200	[thread overview]
Message-ID: <87mvda6rg0.fsf@nikula.org> (raw)
In-Reply-To: <20170225034513.19427-5-david@tethera.net>

On Fri, 24 Feb 2017, David Bremner <david@tethera.net> wrote:
> 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))

Nitpick, excessive braces for my taste!

> +	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)

Side note, looks like we don't consistently check the metadata we want
is really available.

All in all, LGTM.

>  	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
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

      reply	other threads:[~2017-02-25 18:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25  3:45 v1 _notmuch_message_ensure_metadata exception handling David Bremner
2017-02-25  3:45 ` [PATCH 1/4] test: add known broken test for uncaught DatabaseModifiedError David Bremner
2017-02-25 18:49   ` Jani Nikula
2017-02-25 20:08     ` David Bremner
2017-02-25  3:45 ` [PATCH 2/4] lib: add notmuch_database_reopen David Bremner
2017-02-25 18:33   ` Jani Nikula
2017-02-25 20:11     ` David Bremner
2017-02-25  3:45 ` [PATCH 3/4] lib: handle DatabaseModifiedError in _n_message_ensure_metadata David Bremner
2017-02-25 18:42   ` Jani Nikula
2017-02-25 20:21     ` David Bremner
2017-02-25 20:39       ` Jani Nikula
2017-02-25  3:45 ` [PATCH 4/4] lib/message.cc: use view number to invalidate cached metadata David Bremner
2017-02-25 18:44   ` Jani Nikula [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mvda6rg0.fsf@nikula.org \
    --to=jani@nikula.org \
    --cc=david@tethera.net \
    --cc=eg@gaute.vetsj.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).