Re: Batch tagging - add id_list as tag possible?
[notmuch-archives.git] / 93 / e25b3f04eb43a92b743427dbb11955f5ab2147
1 Return-Path: <doctormo@gmail.com>\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 olra.theworths.org (Postfix) with ESMTP id CF508431FD0\r
6         for <notmuch@notmuchmail.org>; Fri,  9 Sep 2011 17:44:00 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id 369nw+Wg805b for <notmuch@notmuchmail.org>;\r
17         Fri,  9 Sep 2011 17:44:00 -0700 (PDT)\r
18 Received: from mail-vw0-f44.google.com (mail-vw0-f44.google.com\r
19         [209.85.212.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id E2F07431FB6\r
22         for <notmuch@notmuchmail.org>; Fri,  9 Sep 2011 17:43:59 -0700 (PDT)\r
23 Received: by vws12 with SMTP id 12so1742450vws.3\r
24         for <notmuch@notmuchmail.org>; Fri, 09 Sep 2011 17:43:57 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=subject:from:to:cc:in-reply-to:references:content-type:date\r
27         :message-id:mime-version:x-mailer;\r
28         bh=A5p27cKREVTskxZ8vgobbgBHiNWHdVzUQh5yW+s/LS0=;\r
29         b=nf/KH0RB1y7nNt595LDdiuxry3DRUxCWfnDIAtkI8z29gT1D6q4E9gcNzOg7S236GI\r
30         Zn7/YW3O+9P5LY3uHUudSWYEgPI45N34zGxdPx7NgXEywoZlYXBVUnR7nkvMMUZi1GUv\r
31         jNulej3JY6mMxwtafBIcB36z71RgTUk5ab0GU=\r
32 Received: by 10.52.69.14 with SMTP id a14mr1232561vdu.410.1315615437814;\r
33         Fri, 09 Sep 2011 17:43:57 -0700 (PDT)\r
34 Received: from [192.168.1.190] (pool-68-163-190-45.bos.east.verizon.net\r
35         [68.163.190.45])\r
36         by mx.google.com with ESMTPS id b18sm2736898vdt.1.2011.09.09.17.43.55\r
37         (version=SSLv3 cipher=OTHER); Fri, 09 Sep 2011 17:43:56 -0700 (PDT)\r
38 Subject: Re: Patch: Flush and Reopen\r
39 From: Martin Owens <doctormo@gmail.com>\r
40 To: Austin Clements <amdragon@mit.edu>\r
41 In-Reply-To:\r
42  <CAH-f9WtuL48RtaJ9njxHyCy5cqhhrxdz+30ydE11rq41Lu06pA@mail.gmail.com>\r
43 References: <1315445674.32058.183.camel@delen>\r
44         <CAH-f9WtuYYuksfTHL1ZMmoRF6kyL7iFu9BXDzGn-wWGniSvf9w@mail.gmail.com>\r
45         <1315536861.2435.34.camel@delen> <87obyuj7q1.fsf@zancas.localnet>\r
46         <1315590950.2435.59.camel@delen>\r
47         <CAH-f9WtuL48RtaJ9njxHyCy5cqhhrxdz+30ydE11rq41Lu06pA@mail.gmail.com>\r
48 Content-Type: multipart/mixed; boundary="=-jr1OYwXDmY6hjg7ZPprb"\r
49 Date: Fri, 09 Sep 2011 20:43:53 -0400\r
50 Message-ID: <1315615433.2435.62.camel@delen>\r
51 Mime-Version: 1.0\r
52 X-Mailer: Evolution 2.30.3 \r
53 Cc: Notmuch developer list <notmuch@notmuchmail.org>\r
54 X-BeenThere: notmuch@notmuchmail.org\r
55 X-Mailman-Version: 2.1.13\r
56 Precedence: list\r
57 List-Id: "Use and development of the notmuch mail system."\r
58         <notmuch.notmuchmail.org>\r
59 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
61 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
62 List-Post: <mailto:notmuch@notmuchmail.org>\r
63 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
64 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
66 X-List-Received-Date: Sat, 10 Sep 2011 00:44:00 -0000\r
67 \r
68 \r
69 --=-jr1OYwXDmY6hjg7ZPprb\r
70 Content-Type: text/plain; charset="UTF-8"\r
71 Content-Transfer-Encoding: 7bit\r
72 \r
73 On Fri, 2011-09-09 at 19:40 -0400, Austin Clements wrote:\r
74\r
75 > (indented correctly, of course).  Reopen is a method of\r
76 > Xapian::Database, which is what notmuch->xapian_db is anyway (unlike,\r
77 > flush, which is a member of the subclass WritableDatabase and hence\r
78 > requires the cast).  And reopening is a sensible thing to do on both\r
79 > read-only and read/write databases.\r
80 \r
81 See attached for the removal of the cast and conditional for reopen.\r
82 \r
83 > Also, in keeping with notmuch code style, you should use tabs for\r
84 > indentation and put a space before the open paren argument lists. \r
85 \r
86 I couldn't detect a consistant style for the tab/spacing and it confused\r
87 me greatly. Especially coming from python where spacing is critical.\r
88 \r
89 I've put in tabs, not sure if I've put in enough in the form required.\r
90 \r
91 Best Regards, Martin Owens\r
92 \r
93 --=-jr1OYwXDmY6hjg7ZPprb\r
94 Content-Disposition: attachment;\r
95  filename*0=0001-Add-flush-and-reopen-methods-to-the-libnotmuch-and-t.pat;\r
96  filename*1=ch\r
97 Content-Type: text/x-patch;\r
98  name="0001-Add-flush-and-reopen-methods-to-the-libnotmuch-and-t.patch";\r
99  charset="UTF-8"\r
100 Content-Transfer-Encoding: 7bit\r
101 \r
102 >From 0d7180fbf271d696e2105420db87aa2d1f0e72aa Mon Sep 17 00:00:00 2001\r
103 From: Martin Owens <doctormo@gmail.com>\r
104 Date: Fri, 9 Sep 2011 20:40:21 -0400\r
105 Subject: [PATCH] Add flush and reopen methods to the libnotmuch and to the python bindings. Flush allows read_write databases to commit their changes, forcing a flush to disk and reopen allows a read_only database to reread from the disk.\r
106 \r
107 Also added a handler for Xapian DatabaseChangedError which occurs when the flush happens to read only databases.\r
108 ---\r
109  bindings/python/notmuch/database.py |   10 ++++++++++\r
110  debian/changelog                    |    6 +++++-\r
111  debian/control                      |    2 +-\r
112  debian/libnotmuch1.symbols          |    2 ++\r
113  lib/database.cc                     |   30 ++++++++++++++++++++++++------\r
114  lib/notmuch.h                       |    8 ++++++++\r
115  6 files changed, 50 insertions(+), 8 deletions(-)\r
116 \r
117 diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
118 index f18ca14..b6c1c31 100644\r
119 --- a/bindings/python/notmuch/database.py\r
120 +++ b/bindings/python/notmuch/database.py\r
121 @@ -432,6 +432,16 @@ class Database(object):\r
122  \r
123          return Query(self, querystring)\r
124  \r
125 +    def reopen(self):\r
126 +        """Reopens a read only database, when the data has changed, this is required."""\r
127 +        if self._db is not None:\r
128 +            nmlib.notmuch_database_reopen(self._db)\r
129 +\r
130 +    def flush(self):\r
131 +        """Flushes the search database, only available when in read-write."""\r
132 +        if self._db is not None:\r
133 +            nmlib.notmuch_database_flush(self._db)\r
134 +\r
135      def __repr__(self):\r
136          return "'Notmuch DB " + self.get_path() + "'"\r
137  \r
138 diff --git a/debian/changelog b/debian/changelog\r
139 index c2b7552..565edfb 100644\r
140 --- a/debian/changelog\r
141 +++ b/debian/changelog\r
142 @@ -1,8 +1,12 @@\r
143  notmuch (0.8~rc1-1) experimental; urgency=low\r
144  \r
145 +  [ David Bremner ]\r
146    * Upstream release candidate.\r
147  \r
148 - -- David Bremner <bremner@debian.org>  Tue, 06 Sep 2011 22:24:24 -0300\r
149 +  [ Martin Owens (DoctorMO) ]\r
150 +  * Re-new-world-order\r
151 +\r
152 + -- Martin Owens (DoctorMO) <doctormo@gmail.com>  Wed, 07 Sep 2011 18:19:50 -0400\r
153  \r
154  notmuch (0.7-1) unstable; urgency=low\r
155  \r
156 diff --git a/debian/control b/debian/control\r
157 index 03afdf4..a72fe1b 100644\r
158 --- a/debian/control\r
159 +++ b/debian/control\r
160 @@ -5,7 +5,7 @@ Maintainer: Carl Worth <cworth@debian.org>\r
161  Uploaders: Jameson Graef Rollins <jrollins@finestructure.net>, martin f. krafft <madduck@debian.org>, \r
162            David Bremner <bremner@debian.org>\r
163  Build-Depends: debhelper (>= 7.0.50~), pkg-config, libxapian-dev, \r
164 - libgmime-2.4-dev, libtalloc-dev, libz-dev,  python-all (>= 2.6.6-3~),\r
165 + libgmime-2.4-dev, libtalloc-dev, libz-dev,  python-all (>= 2.6.6),\r
166   emacs23-nox | emacs23 (>=23~) | emacs23-lucid (>=23~)\r
167  Standards-Version: 3.9.2\r
168  Homepage: http://notmuchmail.org/\r
169 diff --git a/debian/libnotmuch1.symbols b/debian/libnotmuch1.symbols\r
170 index 05d86e6..7e42b0e 100644\r
171 --- a/debian/libnotmuch1.symbols\r
172 +++ b/debian/libnotmuch1.symbols\r
173 @@ -3,6 +3,7 @@ libnotmuch.so.1 libnotmuch1 #MINVER#\r
174   notmuch_database_close@Base 0.3\r
175   notmuch_database_create@Base 0.3\r
176   notmuch_database_find_message@Base 0.3\r
177 + notmuch_database_flush@Base 0.3\r
178   notmuch_database_get_all_tags@Base 0.3\r
179   notmuch_database_get_directory@Base 0.3\r
180   notmuch_database_get_path@Base 0.3\r
181 @@ -10,6 +11,7 @@ libnotmuch.so.1 libnotmuch1 #MINVER#\r
182   notmuch_database_needs_upgrade@Base 0.3\r
183   notmuch_database_open@Base 0.3\r
184   notmuch_database_remove_message@Base 0.3\r
185 + notmuch_database_reopen@Base 0.3\r
186   notmuch_database_upgrade@Base 0.3\r
187   notmuch_directory_destroy@Base 0.3\r
188   notmuch_directory_get_child_directories@Base 0.3\r
189 diff --git a/lib/database.cc b/lib/database.cc\r
190 index 9c2f4ec..557c683 100644\r
191 --- a/lib/database.cc\r
192 +++ b/lib/database.cc\r
193 @@ -700,18 +700,36 @@ notmuch_database_open (const char *path,\r
194  }\r
195  \r
196  void\r
197 -notmuch_database_close (notmuch_database_t *notmuch)\r
198 +notmuch_database_reopen (notmuch_database_t *notmuch)\r
199 +{\r
200 +       try {\r
201 +               notmuch->xapian_db->reopen ();\r
202 +       } catch (const Xapian::Error &error) {\r
203 +               if (! notmuch->exception_reported) {\r
204 +               fprintf (stderr, "Error: A Xapian exception occurred reopening database: %s\n",\r
205 +               error.get_msg().c_str());\r
206 +               }\r
207 +       }\r
208 +}\r
209 +\r
210 +void\r
211 +notmuch_database_flush (notmuch_database_t *notmuch)\r
212  {\r
213      try {\r
214         if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)\r
215 -           (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush ();\r
216 +               (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush ();\r
217      } catch (const Xapian::Error &error) {\r
218 -       if (! notmuch->exception_reported) {\r
219 -           fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n",\r
220 -                    error.get_msg().c_str());\r
221 +               if (! notmuch->exception_reported) {\r
222 +               fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n",\r
223 +               error.get_msg().c_str());\r
224 +               }\r
225         }\r
226 -    }\r
227 +}\r
228  \r
229 +void\r
230 +notmuch_database_close (notmuch_database_t *notmuch)\r
231 +{\r
232 +    notmuch_database_flush (notmuch);\r
233      delete notmuch->term_gen;\r
234      delete notmuch->query_parser;\r
235      delete notmuch->xapian_db;\r
236 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
237 index 974be8d..ca87b89 100644\r
238 --- a/lib/notmuch.h\r
239 +++ b/lib/notmuch.h\r
240 @@ -171,6 +171,14 @@ notmuch_database_t *\r
241  notmuch_database_open (const char *path,\r
242                        notmuch_database_mode_t mode);\r
243  \r
244 +/* Reopen a read_only database when the data source has changed */\r
245 +void\r
246 +notmuch_database_reopen (notmuch_database_t *database);\r
247 +\r
248 +/* Force a flush of the xapian database, also done on close */\r
249 +void\r
250 +notmuch_database_flush (notmuch_database_t *database);\r
251 +\r
252  /* Close the given notmuch database, freeing all associated\r
253   * resources. See notmuch_database_open. */\r
254  void\r
255 -- \r
256 1.7.1\r
257 \r
258 \r
259 --=-jr1OYwXDmY6hjg7ZPprb--\r
260 \r