Re: [PATCH v4 16/16] add "notmuch reindex" subcommand
[notmuch-archives.git] / 87 / 7c2c7136dd4df3224850642cd744b55d589ebe
1 Return-Path: <dkg@fifthhorseman.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id A57F76DE1B50\r
6  for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 12:40:18 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12  autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id 2D317BLYe21J for <notmuch@notmuchmail.org>;\r
16  Sun, 31 Jan 2016 12:40:16 -0800 (PST)\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
18  by arlo.cworth.org (Postfix) with ESMTP id 7A83D6DE1A1C\r
19  for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 12:40:09 -0800 (PST)\r
20 Received: from fifthhorseman.net (ip-64-134-185-108.public.wayport.net\r
21  [64.134.185.108])\r
22  by che.mayfirst.org (Postfix) with ESMTPSA id 9621BF9A0\r
23  for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 15:40:06 -0500 (EST)\r
24 Received: by fifthhorseman.net (Postfix, from userid 1000)\r
25  id 5132421067; Sun, 31 Jan 2016 15:40:06 -0500 (EST)\r
26 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
27 To: Notmuch Mail <notmuch@notmuchmail.org>\r
28 Subject: [PATCH v3 10/16] Add n_d_add_message_with_indexopts (extension of\r
29  n_d_add_message)\r
30 Date: Sun, 31 Jan 2016 15:39:55 -0500\r
31 Message-Id: <1454272801-23623-11-git-send-email-dkg@fifthhorseman.net>\r
32 X-Mailer: git-send-email 2.7.0.rc3\r
33 In-Reply-To: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net>\r
34 References: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net>\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.20\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39  <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
41  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
46  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Sun, 31 Jan 2016 20:40:18 -0000\r
48 \r
49 Expose the ability to ask for index options via the library interface.\r
50 This _add_message_with_indexopts function is now a generalized form of\r
51 the older _add_message.  It lets you specify parameters and\r
52 configurations that can affect the indexing, like indexing encrypted\r
53 messages in the clear should the user choose to do so.\r
54 \r
55 We also adjust the tests so that we test the extended function\r
56 returning bad values (since the non-extended function just calls the\r
57 extended one).\r
58 ---\r
59  lib/database.cc     | 20 ++++++++++++++++----\r
60  lib/notmuch.h       | 14 ++++++++++++++\r
61  test/T070-insert.sh |  4 ++--\r
62  3 files changed, 32 insertions(+), 6 deletions(-)\r
63 \r
64 diff --git a/lib/database.cc b/lib/database.cc\r
65 index 7d88f69..990b0b1 100644\r
66 --- a/lib/database.cc\r
67 +++ b/lib/database.cc\r
68 @@ -2393,16 +2393,16 @@ _notmuch_database_link_message (notmuch_database_t *notmuch,\r
69  }\r
70  \r
71  notmuch_status_t\r
72 -notmuch_database_add_message (notmuch_database_t *notmuch,\r
73 -                             const char *filename,\r
74 -                             notmuch_message_t **message_ret)\r
75 +notmuch_database_add_message_with_indexopts (notmuch_database_t *notmuch,\r
76 +                                            const char *filename,\r
77 +                                            notmuch_indexopts_t *indexopts,\r
78 +                                            notmuch_message_t **message_ret)\r
79  {\r
80      notmuch_message_file_t *message_file;\r
81      notmuch_message_t *message = NULL;\r
82      notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS, ret2;\r
83      notmuch_private_status_t private_status;\r
84      notmuch_bool_t is_ghost = false;\r
85 -    notmuch_indexopts_t *indexopts = NULL;\r
86  \r
87      const char *date, *header;\r
88      const char *from, *to, *subject;\r
89 @@ -2552,6 +2552,18 @@ notmuch_database_add_message (notmuch_database_t *notmuch,\r
90      return ret;\r
91  }\r
92  \r
93 +\r
94 +notmuch_status_t\r
95 +notmuch_database_add_message (notmuch_database_t *notmuch,\r
96 +                             const char *filename,\r
97 +                             notmuch_message_t **message_ret)\r
98 +{\r
99 +    return notmuch_database_add_message_with_indexopts (notmuch, filename,\r
100 +                                                       NULL,\r
101 +                                                       message_ret);\r
102 +    \r
103 +}\r
104 +\r
105  notmuch_status_t\r
106  notmuch_database_remove_message (notmuch_database_t *notmuch,\r
107                                  const char *filename)\r
108 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
109 index 3679c54..854a451 100644\r
110 --- a/lib/notmuch.h\r
111 +++ b/lib/notmuch.h\r
112 @@ -588,6 +588,20 @@ notmuch_status_t\r
113  notmuch_database_add_message (notmuch_database_t *database,\r
114                               const char *filename,\r
115                               notmuch_message_t **message);\r
116 +/**\r
117 + * Add a new message to the given notmuch database or associate an\r
118 + * additional filename with an existing message using specified\r
119 + * options.\r
120 + * \r
121 + * This does the same thing as notmuch_database_add_message except\r
122 + * that it passes a pre-configured set of indexing options to indicate\r
123 + * how the specific message should be indexed.\r
124 + */\r
125 +notmuch_status_t\r
126 +notmuch_database_add_message_with_indexopts (notmuch_database_t *database,\r
127 +                                            const char *filename,\r
128 +                                            notmuch_indexopts_t *indexopts,\r
129 +                                            notmuch_message_t **message);\r
130  \r
131  /**\r
132   * Remove a message filename from the given notmuch database. If the\r
133 diff --git a/test/T070-insert.sh b/test/T070-insert.sh\r
134 index e7ec6a6..557f9d5 100755\r
135 --- a/test/T070-insert.sh\r
136 +++ b/test/T070-insert.sh\r
137 @@ -192,14 +192,14 @@ for code in OUT_OF_MEMORY XAPIAN_EXCEPTION FILE_NOT_EMAIL \\r
138  gen_insert_msg\r
139  cat <<EOF > index-file-$code.gdb\r
140  set breakpoint pending on\r
141 -break notmuch_database_add_message\r
142 +break notmuch_database_add_message_with_indexopts\r
143  commands\r
144  return NOTMUCH_STATUS_$code\r
145  continue\r
146  end\r
147  run\r
148  EOF\r
149 -test_begin_subtest "error exit when add_message returns $code"\r
150 +test_begin_subtest "error exit when add_message_with_indexopts returns $code"\r
151  gdb --batch-silent --return-child-result -x index-file-$code.gdb \\r
152      --args notmuch insert  < $gen_msg_filename\r
153  test_expect_equal $? 1\r
154 -- \r
155 2.7.0.rc3\r
156 \r