unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@freelists.org, notmuch@notmuchmail.org
Subject: [patch v3 07/12] lib: add notmuch_message_count_files
Date: Sun,  4 Jun 2017 09:32:30 -0300	[thread overview]
Message-ID: <20170604123235.24466-8-david@tethera.net> (raw)
In-Reply-To: <20170604123235.24466-1-david@tethera.net>

This operation is relatively inexpensive, as the needed metadata is
already computed by our lazy metadata fetching. The goal is to support
better UI for messages with multipile files.
---
 lib/message.cc        | 8 ++++++++
 lib/notmuch-private.h | 6 ++++++
 lib/notmuch.h         | 8 ++++++++
 lib/string-list.c     | 6 ++++++
 4 files changed, 28 insertions(+)

diff --git a/lib/message.cc b/lib/message.cc
index b330dcce..f3d1e159 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -946,6 +946,14 @@ notmuch_message_get_filenames (notmuch_message_t *message)
     return _notmuch_filenames_create (message, message->filename_list);
 }
 
+int
+notmuch_message_count_files (notmuch_message_t *message)
+{
+    _notmuch_message_ensure_filename_list (message);
+
+    return _notmuch_string_list_length (message->filename_list);
+}
+
 notmuch_bool_t
 notmuch_message_get_flag (notmuch_message_t *message,
 			  notmuch_message_flag_t flag)
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 4534fb52..bcd22bee 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -550,6 +550,12 @@ typedef struct _notmuch_string_list {
 notmuch_string_list_t *
 _notmuch_string_list_create (const void *ctx);
 
+/*
+ * return the number of strings in 'list'
+ */
+int
+_notmuch_string_list_length (notmuch_string_list_t *list);
+
 /* Add 'string' to 'list'.
  *
  * The list will create its own talloced copy of 'string'.
diff --git a/lib/notmuch.h b/lib/notmuch.h
index e1745444..f6ed3990 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1342,6 +1342,14 @@ notmuch_messages_t *
 notmuch_message_get_replies (notmuch_message_t *message);
 
 /**
+ * Get the total number of files associated with a message.
+ * @returns Non-negative integer
+ * @since libnotmuch 5.0 (notmuch 0.25)
+ */
+int
+notmuch_message_count_files (notmuch_message_t *message);
+
+/**
  * Get a filename for the email corresponding to 'message'.
  *
  * The returned filename is an absolute filename, (the initial
diff --git a/lib/string-list.c b/lib/string-list.c
index 43ebe499..9c3ae7ef 100644
--- a/lib/string-list.c
+++ b/lib/string-list.c
@@ -42,6 +42,12 @@ _notmuch_string_list_create (const void *ctx)
     return list;
 }
 
+int
+_notmuch_string_list_length (notmuch_string_list_t *list)
+{
+    return list->length;
+}
+
 void
 _notmuch_string_list_append (notmuch_string_list_t *list,
 			     const char *string)
-- 
2.11.0

  parent reply	other threads:[~2017-06-04 12:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-04 12:32 v3 of index multiple files per msg-id, add reindex command David Bremner
2017-06-04 12:32 ` [patch v3 01/12] lib: isolate n_d_add_message and helper functions into own file David Bremner
2017-06-04 12:32 ` [patch v3 02/12] lib/n_d_add_message: refactor test for new/ghost messages David Bremner
2017-06-04 12:32 ` [patch v3 03/12] lib: factor out message-id parsing to separate file David Bremner
2017-06-04 12:32 ` [patch v3 04/12] lib: refactor notmuch_database_add_message header parsing David Bremner
2017-06-04 12:32 ` [patch v3 05/12] test: add known broken tests for duplicate message id David Bremner
2017-06-04 12:32 ` [patch v3 06/12] lib: index message files with duplicate message-ids David Bremner
2017-06-04 20:34   ` Daniel Kahn Gillmor
2017-06-06  1:09     ` David Bremner
2017-06-09 10:57       ` David Bremner
2017-06-10 20:02     ` [PATCH] fixup! " David Bremner
2017-06-04 12:32 ` David Bremner [this message]
2017-06-04 12:32 ` [patch v3 08/12] lib: add notmuch_thread_get_total_files David Bremner
2017-06-04 12:32 ` [patch v3 09/12] cli/search: print total number of files matched in summary output David Bremner
2017-06-04 12:32 ` [patch v3 10/12] lib: add _notmuch_message_remove_indexed_terms David Bremner
2017-06-04 12:32 ` [patch v3 11/12] lib: add notmuch_message_reindex David Bremner
2017-06-04 12:32 ` [patch v3 12/12] add "notmuch reindex" subcommand David Bremner

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=20170604123235.24466-8-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@freelists.org \
    --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).