1 Return-Path: <amdragon@mit.edu>
\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 4CF9E429E50
\r
6 for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 16:43:47 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 8+eauh1sgLjM for <notmuch@notmuchmail.org>;
\r
16 Wed, 14 Dec 2011 16:43:46 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 54301429E4E
\r
20 for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 16:43:46 -0800 (PST)
\r
21 X-AuditID: 1209190c-b7fad6d000000920-73-4ee942c0501e
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id EF.42.02336.0C249EE4; Wed, 14 Dec 2011 19:43:44 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id pBF0hgFp027837;
\r
27 Wed, 14 Dec 2011 19:43:43 -0500
\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id pBF0heQK009871
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Wed, 14 Dec 2011 19:43:42 -0500 (EST)
\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1RazRc-0001id-0C; Wed, 14 Dec 2011 19:45:08 -0500
\r
37 Date: Wed, 14 Dec 2011 19:45:07 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: Thomas Jost <schnouki@schnouki.net>
\r
40 Subject: Re: [PATCH 2/5] lib: Add a MTIME value to every mail document
\r
41 Message-ID: <20111215004507.GF2760@mit.edu>
\r
42 References: <1323796305-28789-1-git-send-email-schnouki@schnouki.net>
\r
43 <1323796305-28789-3-git-send-email-schnouki@schnouki.net>
\r
45 Content-Type: text/plain; charset=us-ascii
\r
46 Content-Disposition: inline
\r
47 In-Reply-To: <1323796305-28789-3-git-send-email-schnouki@schnouki.net>
\r
48 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
49 X-Brightmail-Tracker:
\r
50 H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hRV1j3g9NLPoGMJp8X1mzOZLfb1+zsw
\r
51 eTxbdYvZY8qsuewBTFFcNimpOZllqUX6dglcGQ1bXjIVNOpVdO/9ydTA+Ei5i5GTQ0LAROL9
\r
52 7snMELaYxIV769m6GLk4hAT2MUosetcP5WxglPjx/hErSJWQwEkmiftzDSESSxgl1i7cyA6S
\r
53 YBFQlXi45TAjiM0moCGxbf9yMFtEQF2iYf5uNhCbWUBa4tvvZiYQW1jATeLb9BtgNq+AtsSv
\r
54 pplMEEMbGSUmL5wDlRCUODnzCQtEs5bEjX8vgeIcYIOW/+MACXMCzZn+sBWsXFRARWLKyW1s
\r
55 ExiFZiHpnoWkexZC9wJG5lWMsim5Vbq5iZk5xanJusXJiXl5qUW6hnq5mSV6qSmlmxjBYS3J
\r
56 s4PxzUGlQ4wCHIxKPLwBh1/4CbEmlhVX5h5ilORgUhLlLbZ96SfEl5SfUpmRWJwRX1Sak1p8
\r
57 iFGCg1lJhLdrL1A5b0piZVVqUT5MSpqDRUmct3rXQz8hgfTEktTs1NSC1CKYrAwHh5IErxIw
\r
58 foUEi1LTUyvSMnNKENJMHJwgw3mAhi9zBKrhLS5IzC3OTIfIn2JUlBLn5QVpFgBJZJTmwfXC
\r
59 0s4rRnGgV4R5FUCqeIApC677FdBgJqDB28NAri4uSURISTUwLn1j4+o173W88bkjWztLDp6X
\r
60 rfzp4HlUYWeRStDPJrN2V+aJZ+I/Mqr2n9IU6i3+lJl7dFmzZlXLxKaidWdmLgxbVGnNb7g2
\r
61 XbP249NXC7fPm/xE9M1n0672w+wSt5vfqfjwxkqnffu1aafp858Ce4/6e2p3/WZ5LBQ0/bLX
\r
62 ouVfgu9mbDitoMRSnJFoqMVcVJwIAHAzwR0WAwAA
\r
63 Cc: notmuch@notmuchmail.org
\r
64 X-BeenThere: notmuch@notmuchmail.org
\r
65 X-Mailman-Version: 2.1.13
\r
67 List-Id: "Use and development of the notmuch mail system."
\r
68 <notmuch.notmuchmail.org>
\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
72 List-Post: <mailto:notmuch@notmuchmail.org>
\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
75 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
76 X-List-Received-Date: Thu, 15 Dec 2011 00:43:47 -0000
\r
78 A few minor comments below.
\r
80 At a higher level, I'm curious what the tag synchronization protocol
\r
81 you're building on top of this is. I can't think of one that doesn't
\r
82 have race conditions, but maybe I'm not thinking about it right.
\r
84 Quoth Thomas Jost on Dec 13 at 6:11 pm:
\r
85 > This is a time_t value, similar to the message date (TIMESTAMP). It is first set
\r
86 > when the message is added to the database, and is then updated every time a tag
\r
87 > is added or removed. It can thus be used for doing incremental dumps of the
\r
88 > database or for synchronizing it between several computers.
\r
90 > This value can be read freely (with notmuch_message_get_mtime()) but for now it
\r
91 > can't be set to an arbitrary value: it can only be set to "now" when updated.
\r
92 > There's no specific reason for this except that I don't really see a real use
\r
93 > case for setting it to an arbitrary value.
\r
95 > lib/database.cc | 7 ++++++-
\r
96 > lib/message.cc | 32 ++++++++++++++++++++++++++++++++
\r
97 > lib/notmuch-private.h | 6 +++++-
\r
98 > lib/notmuch.h | 4 ++++
\r
99 > 4 files changed, 47 insertions(+), 2 deletions(-)
\r
101 > diff --git a/lib/database.cc b/lib/database.cc
\r
102 > index 2025189..6dc6f73 100644
\r
103 > --- a/lib/database.cc
\r
104 > +++ b/lib/database.cc
\r
105 > @@ -81,7 +81,7 @@ typedef struct {
\r
106 > * STRING is the name of a file within that
\r
107 > * directory for this mail message.
\r
109 > - * A mail document also has four values:
\r
110 > + * A mail document also has five values:
\r
112 > * TIMESTAMP: The time_t value corresponding to the message's
\r
114 > @@ -92,6 +92,9 @@ typedef struct {
\r
116 > * SUBJECT: The value of the "Subject" header
\r
118 > + * MTIME: The time_t value corresponding to the last time
\r
119 > + * a tag was added or removed on the message.
\r
121 > * In addition, terms from the content of the message are added with
\r
122 > * "from", "to", "attachment", and "subject" prefixes for use by the
\r
123 > * user in searching. Similarly, terms from the path of the mail
\r
124 > @@ -1735,6 +1738,8 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
125 > date = notmuch_message_file_get_header (message_file, "date");
\r
126 > _notmuch_message_set_header_values (message, date, from, subject);
\r
128 > + _notmuch_message_update_mtime (message);
\r
133 > _notmuch_message_index_file (message, filename);
\r
135 > ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
\r
136 > diff --git a/lib/message.cc b/lib/message.cc
\r
137 > index 0075425..0c98589 100644
\r
138 > --- a/lib/message.cc
\r
139 > +++ b/lib/message.cc
\r
140 > @@ -830,6 +830,34 @@ _notmuch_message_set_header_values (notmuch_message_t *message,
\r
141 > message->doc.add_value (NOTMUCH_VALUE_SUBJECT, subject);
\r
144 > +/* Get the message mtime, i.e. when it was added or the last time a tag was
\r
145 > + * added/removed. */
\r
147 > +notmuch_message_get_mtime (notmuch_message_t *message)
\r
149 > + std::string value;
\r
152 > + value = message->doc.get_value (NOTMUCH_VALUE_MTIME);
\r
153 > + } catch (Xapian::Error &error) {
\r
154 > + INTERNAL_ERROR ("Failed to read mtime value from document.");
\r
158 For compatibility, this should handle the case when
\r
159 NOTMUCH_VALUE_MTIME is missing, probably by just returning 0. As it
\r
160 is, value will be an empty string and sortable_unserialise is
\r
161 undefined on strings that weren't produced by sortable_serialise.
\r
164 > + return Xapian::sortable_unserialise (value);
\r
167 > +/* Set the message mtime to "now". */
\r
169 > +_notmuch_message_update_mtime (notmuch_message_t *message)
\r
171 > + time_t time_value;
\r
173 > + time_value = time (NULL);
\r
174 > + message->doc.add_value (NOTMUCH_VALUE_MTIME,
\r
175 > + Xapian::sortable_serialise (time_value));
\r
181 > /* Synchronize changes made to message->doc out into the database. */
\r
183 > _notmuch_message_sync (notmuch_message_t *message)
\r
184 > @@ -994,6 +1022,8 @@ notmuch_message_add_tag (notmuch_message_t *message, const char *tag)
\r
188 > + _notmuch_message_update_mtime (message);
\r
190 > if (! message->frozen)
\r
191 > _notmuch_message_sync (message);
\r
193 > @@ -1022,6 +1052,8 @@ notmuch_message_remove_tag (notmuch_message_t *message, const char *tag)
\r
197 > + _notmuch_message_update_mtime (message);
\r
199 > if (! message->frozen)
\r
200 > _notmuch_message_sync (message);
\r
202 > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
203 > index 60a932f..9859872 100644
\r
204 > --- a/lib/notmuch-private.h
\r
205 > +++ b/lib/notmuch-private.h
\r
206 > @@ -95,7 +95,8 @@ typedef enum {
\r
207 > NOTMUCH_VALUE_TIMESTAMP = 0,
\r
208 > NOTMUCH_VALUE_MESSAGE_ID,
\r
209 > NOTMUCH_VALUE_FROM,
\r
210 > - NOTMUCH_VALUE_SUBJECT
\r
211 > + NOTMUCH_VALUE_SUBJECT,
\r
212 > + NOTMUCH_VALUE_MTIME
\r
213 > } notmuch_value_t;
\r
215 > /* Xapian (with flint backend) complains if we provide a term longer
\r
216 > @@ -276,6 +277,9 @@ _notmuch_message_set_header_values (notmuch_message_t *message,
\r
217 > const char *from,
\r
218 > const char *subject);
\r
220 > +_notmuch_message_update_mtime (notmuch_message_t *message);
\r
223 > _notmuch_message_sync (notmuch_message_t *message);
\r
226 > diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
227 > index 9f23a10..643ebce 100644
\r
228 > --- a/lib/notmuch.h
\r
229 > +++ b/lib/notmuch.h
\r
230 > @@ -910,6 +910,10 @@ notmuch_message_set_flag (notmuch_message_t *message,
\r
232 > notmuch_message_get_date (notmuch_message_t *message);
\r
234 > +/* Get the mtime of 'message' as a time_t value. */
\r
236 > +notmuch_message_get_mtime (notmuch_message_t *message);
\r
238 > /* Get the value of the specified header from 'message'.
\r
240 > * The value will be read from the actual message file, not from the
\r