[PATCH 2/2] emacs: Change the default thousands separator to a space
[notmuch-archives.git] / f4 / 86ceac075a9091ecb4e5acd1153840184bcd07
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 66CCA431FD0\r
6         for <notmuch@notmuchmail.org>; Fri,  9 Sep 2011 10:55:55 -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 LyjXEqodE8wC for <notmuch@notmuchmail.org>;\r
17         Fri,  9 Sep 2011 10:55:54 -0700 (PDT)\r
18 Received: from mail-vx0-f181.google.com (mail-vx0-f181.google.com\r
19         [209.85.220.181]) (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 9B746431FB6\r
22         for <notmuch@notmuchmail.org>; Fri,  9 Sep 2011 10:55:54 -0700 (PDT)\r
23 Received: by vxl15 with SMTP id 15so784951vxl.26\r
24         for <notmuch@notmuchmail.org>; Fri, 09 Sep 2011 10:55:53 -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=LohzRBi4oCA1Uv/AGNGwyvoNqk+88ZyGTjnREnLyvMk=;\r
29         b=HPCgc3QlZ3J1MnbxSmsub7S7BIQjZqeVQj779CTcNFr7MAEDeLeLgMD1kFHoWIh6sw\r
30         QQQk9QEC39NPlwDlDYkTv5zHxeMQij+ep8n0UTUyq8LilmhOugzjSPN+aoCKBr3ZKSZN\r
31         Sp9yo+16lfCmhcY9lDMTq4zbFes17IltQ1q48=\r
32 Received: by 10.52.22.84 with SMTP id b20mr2328082vdf.413.1315590952959;\r
33         Fri, 09 Sep 2011 10:55:52 -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 be17sm5173198vdc.15.2011.09.09.10.55.50\r
37         (version=SSLv3 cipher=OTHER); Fri, 09 Sep 2011 10:55:51 -0700 (PDT)\r
38 Subject: Re: Patch: Flush and Reopen\r
39 From: Martin Owens <doctormo@gmail.com>\r
40 To: David Bremner <david@tethera.net>\r
41 In-Reply-To: <87obyuj7q1.fsf@zancas.localnet>\r
42 References: <1315445674.32058.183.camel@delen>\r
43         <CAH-f9WtuYYuksfTHL1ZMmoRF6kyL7iFu9BXDzGn-wWGniSvf9w@mail.gmail.com>\r
44         <1315536861.2435.34.camel@delen>  <87obyuj7q1.fsf@zancas.localnet>\r
45 Content-Type: multipart/mixed; boundary="=-if+DZnU/UI8bcf6/7HDh"\r
46 Date: Fri, 09 Sep 2011 13:55:50 -0400\r
47 Message-ID: <1315590950.2435.59.camel@delen>\r
48 Mime-Version: 1.0\r
49 X-Mailer: Evolution 2.30.3 \r
50 Cc: Notmuch developer list <notmuch@notmuchmail.org>\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Fri, 09 Sep 2011 17:55:55 -0000\r
64 \r
65 \r
66 --=-if+DZnU/UI8bcf6/7HDh\r
67 Content-Type: text/plain; charset="UTF-8"\r
68 Content-Transfer-Encoding: 7bit\r
69 \r
70 On Fri, 2011-09-09 at 08:06 -0300, David Bremner wrote:\r
71 > I was also puzzled by your changes to debian/changelog. We really need\r
72 > justification for every little change introduced by the patch; this is\r
73 > another reason it helps to split things up a bit. \r
74 \r
75 That probably was unintended. See attached for the all new slimmed down\r
76 patch.\r
77 \r
78 I've removed the debian control change, the changelog change, the extra\r
79 error catch in query.cc and put that cast right.\r
80 \r
81 I'll leave the version of python-all for someone else.\r
82 \r
83 Best Regards, Martin Owens\r
84 \r
85 --=-if+DZnU/UI8bcf6/7HDh\r
86 Content-Disposition: attachment;\r
87  filename*0=0001-Add-flush-and-reopen-methods-to-the-libnotmuch-and-t.pat;\r
88  filename*1=ch\r
89 Content-Type: text/x-patch;\r
90  name="0001-Add-flush-and-reopen-methods-to-the-libnotmuch-and-t.patch";\r
91  charset="UTF-8"\r
92 Content-Transfer-Encoding: 7bit\r
93 \r
94 >From 981b91e9405de2daf35d30d9bbeab0dd62b15683 Mon Sep 17 00:00:00 2001\r
95 From: Martin Owens <doctormo@gmail.com>\r
96 Date: Fri, 9 Sep 2011 13:51:59 -0400\r
97 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
98 \r
99 Also added a handler for Xapian DatabaseChangedError which occurs when the flush happens to read only databases.\r
100 ---\r
101  bindings/python/notmuch/database.py |   10 ++++++++++\r
102  debian/libnotmuch1.symbols          |    2 ++\r
103  lib/database.cc                     |   33 ++++++++++++++++++++++++++-------\r
104  lib/notmuch.h                       |    8 ++++++++\r
105  4 files changed, 46 insertions(+), 7 deletions(-)\r
106 \r
107 diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
108 index f18ca14..b6c1c31 100644\r
109 --- a/bindings/python/notmuch/database.py\r
110 +++ b/bindings/python/notmuch/database.py\r
111 @@ -432,6 +432,16 @@ class Database(object):\r
112  \r
113          return Query(self, querystring)\r
114  \r
115 +    def reopen(self):\r
116 +        """Reopens a read only database, when the data has changed, this is required."""\r
117 +        if self._db is not None:\r
118 +            nmlib.notmuch_database_reopen(self._db)\r
119 +\r
120 +    def flush(self):\r
121 +        """Flushes the search database, only available when in read-write."""\r
122 +        if self._db is not None:\r
123 +            nmlib.notmuch_database_flush(self._db)\r
124 +\r
125      def __repr__(self):\r
126          return "'Notmuch DB " + self.get_path() + "'"\r
127  \r
128 diff --git a/debian/libnotmuch1.symbols b/debian/libnotmuch1.symbols\r
129 index 05d86e6..7e42b0e 100644\r
130 --- a/debian/libnotmuch1.symbols\r
131 +++ b/debian/libnotmuch1.symbols\r
132 @@ -3,6 +3,7 @@ libnotmuch.so.1 libnotmuch1 #MINVER#\r
133   notmuch_database_close@Base 0.3\r
134   notmuch_database_create@Base 0.3\r
135   notmuch_database_find_message@Base 0.3\r
136 + notmuch_database_flush@Base 0.3\r
137   notmuch_database_get_all_tags@Base 0.3\r
138   notmuch_database_get_directory@Base 0.3\r
139   notmuch_database_get_path@Base 0.3\r
140 @@ -10,6 +11,7 @@ libnotmuch.so.1 libnotmuch1 #MINVER#\r
141   notmuch_database_needs_upgrade@Base 0.3\r
142   notmuch_database_open@Base 0.3\r
143   notmuch_database_remove_message@Base 0.3\r
144 + notmuch_database_reopen@Base 0.3\r
145   notmuch_database_upgrade@Base 0.3\r
146   notmuch_directory_destroy@Base 0.3\r
147   notmuch_directory_get_child_directories@Base 0.3\r
148 diff --git a/lib/database.cc b/lib/database.cc\r
149 index 9c2f4ec..b86bf1a 100644\r
150 --- a/lib/database.cc\r
151 +++ b/lib/database.cc\r
152 @@ -700,18 +700,37 @@ notmuch_database_open (const char *path,\r
153  }\r
154  \r
155  void\r
156 -notmuch_database_close (notmuch_database_t *notmuch)\r
157 +notmuch_database_reopen (notmuch_database_t *notmuch)\r
158  {\r
159      try {\r
160 -       if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)\r
161 -           (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush ();\r
162 +        if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY)\r
163 +            (static_cast <Xapian::Database *> (notmuch->xapian_db))->reopen();\r
164      } catch (const Xapian::Error &error) {\r
165 -       if (! notmuch->exception_reported) {\r
166 -           fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n",\r
167 -                    error.get_msg().c_str());\r
168 -       }\r
169 +        if (! notmuch->exception_reported) {\r
170 +            fprintf (stderr, "Error: A Xapian exception occurred reopening database: %s\n",\r
171 +                error.get_msg().c_str());\r
172 +        }\r
173      }\r
174 +}\r
175  \r
176 +void\r
177 +notmuch_database_flush (notmuch_database_t *notmuch)\r
178 +{\r
179 +    try {\r
180 +        if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)\r
181 +            (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->flush();\r
182 +    } catch (const Xapian::Error &error) {\r
183 +        if (! notmuch->exception_reported) {\r
184 +            fprintf (stderr, "Error: A Xapian exception occurred flushing database: %s\n",\r
185 +                error.get_msg().c_str());\r
186 +        }\r
187 +    }\r
188 +}\r
189 +\r
190 +void\r
191 +notmuch_database_close (notmuch_database_t *notmuch)\r
192 +{\r
193 +    notmuch_database_flush (notmuch);\r
194      delete notmuch->term_gen;\r
195      delete notmuch->query_parser;\r
196      delete notmuch->xapian_db;\r
197 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
198 index 974be8d..ca87b89 100644\r
199 --- a/lib/notmuch.h\r
200 +++ b/lib/notmuch.h\r
201 @@ -171,6 +171,14 @@ notmuch_database_t *\r
202  notmuch_database_open (const char *path,\r
203                        notmuch_database_mode_t mode);\r
204  \r
205 +/* Reopen a read_only database when the data source has changed */\r
206 +void\r
207 +notmuch_database_reopen (notmuch_database_t *database);\r
208 +\r
209 +/* Force a flush of the xapian database, also done on close */\r
210 +void\r
211 +notmuch_database_flush (notmuch_database_t *database);\r
212 +\r
213  /* Close the given notmuch database, freeing all associated\r
214   * resources. See notmuch_database_open. */\r
215  void\r
216 -- \r
217 1.7.1\r
218 \r
219 \r
220 --=-if+DZnU/UI8bcf6/7HDh--\r
221 \r