Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / 74 / cb0f1a63fd249ce1df301f086d8796d1422e81
1 Return-Path: <mforney@mforney.org>\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 DD0F5431E62\r
6         for <notmuch@notmuchmail.org>; Mon, 10 Dec 2012 22:55:40 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id KWajkUoXeqYW for <notmuch@notmuchmail.org>;\r
16         Mon, 10 Dec 2012 22:55:38 -0800 (PST)\r
17 Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com\r
18         [209.85.220.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 43F41431FBD\r
21         for <notmuch@notmuchmail.org>; Mon, 10 Dec 2012 22:55:35 -0800 (PST)\r
22 Received: by mail-pa0-f53.google.com with SMTP id hz1so2441344pad.26\r
23         for <notmuch@notmuchmail.org>; Mon, 10 Dec 2012 22:55:34 -0800 (PST)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=google.com; s=20120113;\r
26         h=from:to:subject:date:message-id:x-mailer:in-reply-to:references\r
27         :x-gm-message-state;\r
28         bh=fFHCugg9BZ3Fa8/VqMQ+ulpnCigvY1hBCSaocgGH6PI=;\r
29         b=nz8F6L1WtFas2plH9zvUwBD69P/dNGIkce/6im69WIMamqEgKwWOZ8FgxIaOrqHgNZ\r
30         Xk/+6jd2ELE2CRicOD0eZqV2mfu4+njeozDYI1RbmsXrfPpI6jObChVh78ApdsH9s5e2\r
31         Wz6lRQKhx0k3kYSk66Q9z2xnUteSZlsoQN19PSfW0YazabsPdca5me9aBcCaXVxcYzqE\r
32         udzLYLbXo3i2HOZcR3GXFZ2olZAIYkqEwYuBrzYU29JocinQVj36Rb+H3Z1ni3ESKdkU\r
33         QGuzuKR129s9aG0lHYm1qy3cMd9vNlXSTabmOEAglsMELVwQPcQ+lnGFiY3sqFhcQIJw\r
34         hiyg==\r
35 Received: by 10.68.235.71 with SMTP id uk7mr46230860pbc.10.1355208934587;\r
36         Mon, 10 Dec 2012 22:55:34 -0800 (PST)\r
37 Received: from localhost ([2601:9:580:4c:21f:16ff:fe34:119e])\r
38         by mx.google.com with ESMTPS id pm8sm11992599pbb.29.2012.12.10.22.55.33\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Mon, 10 Dec 2012 22:55:34 -0800 (PST)\r
41 From: Michael Forney <mforney@mforney.org>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH 2/2] lib: Allow synchronizing message changes with a separate\r
44         database connection\r
45 Date: Mon, 10 Dec 2012 22:54:53 -0800\r
46 Message-Id: <1355208893-16122-3-git-send-email-mforney@mforney.org>\r
47 X-Mailer: git-send-email 1.8.0\r
48 In-Reply-To: <1355208893-16122-1-git-send-email-mforney@mforney.org>\r
49 References: <1355208893-16122-1-git-send-email-mforney@mforney.org>\r
50 X-Gm-Message-State:\r
51  ALoCoQk9lzXuL/ZXZHE/Jyv25ryZu7qNGGLxJVSuO8wlnrWaXQ7rJL2Yv/SWmRaSElTqziflFR20\r
52 X-BeenThere: notmuch@notmuchmail.org\r
53 X-Mailman-Version: 2.1.13\r
54 Precedence: list\r
55 List-Id: "Use and development of the notmuch mail system."\r
56         <notmuch.notmuchmail.org>\r
57 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
59 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
60 List-Post: <mailto:notmuch@notmuchmail.org>\r
61 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
62 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
64 X-List-Received-Date: Tue, 11 Dec 2012 06:55:41 -0000\r
65 \r
66 The motivation for this patch is that in some cases, it is ideal to open\r
67 a read-only database, and only open the database as writable when we\r
68 need to make changes to a message. This way, we don't block other\r
69 programs to write to the database when we don't need to.\r
70 \r
71 With the current system, in order to modify a tag of a message opened\r
72 read-only, I would have to find the message in a writable database with\r
73 my read-only message's ID, which would cause unnecessary reads from the\r
74 database, and seems overly complicated for a simple operation (replace\r
75 document).\r
76 ---\r
77  bindings/go/src/notmuch/notmuch.go |  3 ++-\r
78  bindings/python/notmuch/message.py |  4 +++-\r
79  lib/database.cc                    |  7 +++++++\r
80  lib/notmuch.h                      | 26 +++++++++++++++++++++++---\r
81  4 files changed, 35 insertions(+), 5 deletions(-)\r
82 \r
83 diff --git a/bindings/go/src/notmuch/notmuch.go b/bindings/go/src/notmuch/notmuch.go\r
84 index 56eb710..85c6620 100644\r
85 --- a/bindings/go/src/notmuch/notmuch.go\r
86 +++ b/bindings/go/src/notmuch/notmuch.go\r
87 @@ -957,7 +957,8 @@ func (self *Message) RemoveAllTags() Status {\r
88   *    notmuch_message_sync (message);\r
89   *\r
90   * This method only works if the database associated with 'message' was\r
91 - * opened in read-write mode.\r
92 + * opened in read-write mode. If you wish make changes to a message\r
93 + * opened with a read-only database, see notmuch_database_sync_message.\r
94   *\r
95   * Return value:\r
96   *\r
97 diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py\r
98 index 600c01e..b4f2d25 100644\r
99 --- a/bindings/python/notmuch/message.py\r
100 +++ b/bindings/python/notmuch/message.py\r
101 @@ -420,7 +420,9 @@ class Message(Python3StringMixIn):\r
102            msg.tags_to_maildir_flags()\r
103  \r
104          This method only works if the database associated with 'message' was\r
105 -        opened with NOTMUCH_DATABASE_MODE_READ_WRITE.\r
106 +        opened with NOTMUCH_DATABASE_MODE_READ_WRITE. If you wish make\r
107 +        changes to a message opened with a read-only database, see\r
108 +        notmuch_database_sync_message.\r
109  \r
110          :param sync_maildir_flags: If notmuch configuration is set to do\r
111              this, add maildir flags corresponding to notmuch tags. See\r
112 diff --git a/lib/database.cc b/lib/database.cc\r
113 index 98ea789..a9718ab 100644\r
114 --- a/lib/database.cc\r
115 +++ b/lib/database.cc\r
116 @@ -388,6 +388,13 @@ notmuch_database_find_message (notmuch_database_t *notmuch,\r
117      }\r
118  }\r
119  \r
120 +notmuch_status_t\r
121 +notmuch_database_sync_message (notmuch_database_t *notmuch,\r
122 +                              notmuch_message_t *message)\r
123 +{\r
124 +    return _notmuch_message_sync_to_database (message, notmuch);\r
125 +}\r
126 +\r
127  /* Advance 'str' past any whitespace or RFC 822 comments. A comment is\r
128   * a (potentially nested) parenthesized sequence with '\' used to\r
129   * escape any character (including parentheses).\r
130 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
131 index f6962ee..1570917 100644\r
132 --- a/lib/notmuch.h\r
133 +++ b/lib/notmuch.h\r
134 @@ -446,6 +446,23 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,\r
135                                            const char *filename,\r
136                                            notmuch_message_t **message);\r
137  \r
138 +/* Synchronize the current state of 'message' into the given database.\r
139 + *\r
140 + * This is a more general version of notmuch_message_sync, allowing you\r
141 + * to synchronize changes to a message opened with a read-only database\r
142 + * into a writable database.\r
143 + *\r
144 + * Return value:\r
145 + *\r
146 + * NOTMUCH_STATUS_SUCCESS: Message successfully synchronized.\r
147 + *\r
148 + * NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in read-only\r
149 + *     mode so message cannot be modified.\r
150 + */\r
151 +notmuch_status_t\r
152 +notmuch_database_sync_message (notmuch_database_t *notmuch,\r
153 +                              notmuch_message_t *message);\r
154 +\r
155  /* Return a list of all tags found in the database.\r
156   *\r
157   * This function creates a list of all tags found in the database. The\r
158 @@ -1040,7 +1057,8 @@ notmuch_message_get_tags (notmuch_message_t *message);\r
159  /* Add a tag to the given message.\r
160   *\r
161   * The changes to the message will not be committed into the database\r
162 - * until notmuch_message_sync is called.\r
163 + * until notmuch_message_sync or notmuch_database_sync_message is\r
164 + * called.\r
165   *\r
166   * Return value:\r
167   *\r
168 @@ -1057,7 +1075,8 @@ notmuch_message_add_tag (notmuch_message_t *message, const char *tag);\r
169  /* Remove a tag from the given message.\r
170   *\r
171   * The changes to the message will not be committed into the database\r
172 - * until notmuch_message_sync is called.\r
173 + * until notmuch_message_sync or notmuch_database_sync_message is\r
174 + * called.\r
175   *\r
176   * Return value:\r
177   *\r
178 @@ -1171,7 +1190,8 @@ notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);\r
179   *    notmuch_message_sync (message);\r
180   *\r
181   * This method only works if the database associated with 'message' was\r
182 - * opened in read-write mode.\r
183 + * opened in read-write mode. If you wish make changes to a message\r
184 + * opened with a read-only database, see notmuch_database_sync_message.\r
185   *\r
186   * Return value:\r
187   *\r
188 -- \r
189 1.8.0\r
190 \r