1 Return-Path: <glasse@cs.rpi.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 6D518429E48
\r
6 for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:11:17 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.54 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 RCVD_IN_BL_SPAMCOP_NET=1.246, RCVD_IN_DNSWL_MED=-2.3,
\r
14 RCVD_IN_SORBS_WEB=0.614] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id 5Ccl3Vh7Qb3I for <notmuch@notmuchmail.org>;
\r
18 Wed, 15 Feb 2012 14:11:13 -0800 (PST)
\r
19 Received: from cliffclavin.cs.rpi.edu (cliffclavin.cs.rpi.edu
\r
20 [128.113.126.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
21 (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS
\r
22 id B2208429E43 for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:11:13 -0800
\r
25 S|a57180726c74ee2ac7421b5b6afc127d9861b50d|f4c71ca8cd81772447cd914142de4b6b
\r
26 X-Countries: Cameroon, United States
\r
27 X-SMTP-From: accepted <glasse@cs.rpi.edu> [195.24.209.20] [195.24.209.20]
\r
28 (localhost) {Cameroon}
\r
29 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=cs.rpi.edu; h=from
\r
30 :to:cc:subject:date:message-id:in-reply-to:references; s=
\r
31 default; i=glasse@cs.rpi.edu; t=1329343871; x=1329948671; l=6206;
\r
32 bh=yMg95QHC9rjdhpvXA3C3pEILpds=; b=KPs/FicgdLWwKm5MvN2+tNv
\r
33 FoOFOlGTwMtqb3vrO5PIKNU7TNR3PEiSKhmbvMaqtJJ1J7pRm4F6BChHcq0tDhmZ
\r
34 MYllAwKxNWjBGwP5Q6AzceyUNjRrQD5gbz/3/vQdtrWCcRFySqlZcZ+cevHuaMrf
\r
35 lvlpUZTnYA8MhuWRiDFc=
\r
36 DomainKey-Signature: a=rsa-sha1; c=nofws; d=cs.rpi.edu; h=from:to:cc
\r
37 :subject:date:message-id:in-reply-to:references; q=dns; s=
\r
38 default; b=dkuFtjxlcjmSruqxn5aKnbFRj1ZNIIGmoVhX1IWdhO0znn5Y2T+g+
\r
39 ccv/6k19gUR4U35qHzb0ytig64FdlzMlMkYYG2JVWuyqBvIgK+cLFzOrZkS0gNis
\r
40 LD36shUORy7x9lYbec9bEBcKeCOjIOxoAJMqrU4zB4+K4dGXkdUpY0=
\r
41 X-Spam-Info: -2.7; ALL_TRUSTED,AWL,BAYES_00
\r
42 X-Spam-Scanned-By: cliffclavin.cs.rpi.edu using SpamAssassin 3.2.5 (hard limit
\r
44 Authentication-Results: cliffclavin.cs.rpi.edu;
\r
45 DKIM=neutral (none) header.from=glasse@cs.rpi.edu;
\r
47 Mechanism '?all' matched) smtp.mail=glasse@cs.rpi.edu
\r
48 X-Auth-Passed: cliffclavin.cs.rpi.edu:q1FMAgD5008841 Auth:glasse
\r
49 X-Virus-Scanned-By: cliffclavin.cs.rpi.edu
\r
50 Received: from localhost ([195.24.209.20]) (authenticated bits=0)
\r
51 by cliffclavin.cs.rpi.edu (8.14.3/8.14.3) with ESMTP id q1FMAgD5008841
\r
52 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);
\r
53 Wed, 15 Feb 2012 17:10:54 -0500 (EST)
\r
54 (envelope-from glasse@cs.rpi.edu)
\r
55 From: Ethan Glasser-Camp <glasse@cs.rpi.edu>
\r
56 To: notmuch@notmuchmail.org
\r
57 Subject: [RFC PATCH 09/13] Mailstore also provides a "rename" function
\r
58 Date: Wed, 15 Feb 2012 17:02:02 -0500
\r
59 Message-Id: <1329343326-16410-10-git-send-email-glasse@cs.rpi.edu>
\r
60 X-Mailer: git-send-email 1.7.5.4
\r
61 In-Reply-To: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>
\r
62 References: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>
\r
63 X-Scanned-By: MIMEDefang 2.67 on 128.113.126.25
\r
64 Cc: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
65 X-BeenThere: notmuch@notmuchmail.org
\r
66 X-Mailman-Version: 2.1.13
\r
68 List-Id: "Use and development of the notmuch mail system."
\r
69 <notmuch.notmuchmail.org>
\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
73 List-Post: <mailto:notmuch@notmuchmail.org>
\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
76 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
77 X-List-Received-Date: Wed, 15 Feb 2012 22:11:17 -0000
\r
79 From: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
81 This is used only in notmuch_message_tags_to_maildir_flags, to update
\r
82 a message's filename when its tags change. For mailstores where this
\r
83 doesn't make sense, they can of course define rename to be a NOOP.
\r
85 Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
87 lib/mailstore.c | 21 ++++++++++++++++++++-
\r
88 lib/message.cc | 5 +++--
\r
89 lib/notmuch.h | 10 +++++++++-
\r
90 notmuch-restore.c | 7 +++++--
\r
91 notmuch-tag.c | 7 +++++--
\r
92 5 files changed, 42 insertions(+), 8 deletions(-)
\r
94 diff --git a/lib/mailstore.c b/lib/mailstore.c
\r
95 index 290da70..2c6beab 100644
\r
96 --- a/lib/mailstore.c
\r
97 +++ b/lib/mailstore.c
\r
100 typedef struct _notmuch_mailstore {
\r
101 FILE *(*open) (struct _notmuch_mailstore *mailstore, const char *filename);
\r
102 + int (*rename) (struct _notmuch_mailstore *mailstore, const char *old_filename,
\r
103 + const char *new_filename);
\r
104 } _notmuch_mailstore;
\r
107 @@ -31,17 +33,27 @@ _maildir_open_function (unused (notmuch_mailstore_t *mailstore),
\r
108 return fopen (filename, "r");
\r
112 +_maildir_rename_function (unused (notmuch_mailstore_t *mailstore),
\r
113 + const char *old_filename, const char *new_filename)
\r
115 + return rename (old_filename, new_filename);
\r
118 /* A mailstore is defined as:
\r
120 * - A function used to "open" a mail message. This takes the
\r
121 * "filename" for the file and should return a FILE *.
\r
123 + * - A function to "rename" a mail message, which is currently only
\r
124 + * used in tags_to_maildir_flags.
\r
126 * - TODO: A way to scan for new messages?
\r
128 * - TODO: A "constructor"?
\r
131 -notmuch_mailstore_maildir = { _maildir_open_function };
\r
132 +notmuch_mailstore_maildir = { _maildir_open_function, _maildir_rename_function };
\r
134 _notmuch_mailstore *
\r
135 notmuch_mailstore_get_by_name (const char *name)
\r
136 @@ -57,3 +69,10 @@ notmuch_mailstore_open (notmuch_mailstore_t *mailstore, const char *filename)
\r
138 return mailstore->open (mailstore, filename);
\r
142 +notmuch_mailstore_rename (notmuch_mailstore_t *mailstore, const char *old_filename,
\r
143 + const char *new_filename)
\r
145 + return mailstore->rename (mailstore, old_filename, new_filename);
\r
147 diff --git a/lib/message.cc b/lib/message.cc
\r
148 index 762a18f..cd81f6b 100644
\r
149 --- a/lib/message.cc
\r
150 +++ b/lib/message.cc
\r
151 @@ -1291,7 +1291,8 @@ _new_maildir_filename (void *ctx,
\r
155 -notmuch_message_tags_to_maildir_flags (notmuch_message_t *message)
\r
156 +notmuch_message_tags_to_maildir_flags (notmuch_mailstore_t *mailstore,
\r
157 + notmuch_message_t *message)
\r
159 notmuch_filenames_t *filenames;
\r
160 const char *filename;
\r
161 @@ -1319,7 +1320,7 @@ notmuch_message_tags_to_maildir_flags (notmuch_message_t *message)
\r
163 notmuch_status_t new_status;
\r
165 - err = rename (filename, filename_new);
\r
166 + err = notmuch_mailstore_rename (mailstore, filename, filename_new);
\r
170 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
171 index 7ebe034..b6e66a9 100644
\r
172 --- a/lib/notmuch.h
\r
173 +++ b/lib/notmuch.h
\r
174 @@ -423,6 +423,13 @@ notmuch_mailstore_get_by_name (const char *name);
\r
176 notmuch_mailstore_open (notmuch_mailstore_t *mailstore, const char *filename);
\r
178 +/* Rename a file. This is used to update maildir tags and can safely
\r
179 + * be a NO-OP for non-filesystem mailstores.
\r
182 +notmuch_mailstore_rename (notmuch_mailstore_t *mailstore, const char *old_filename,
\r
183 + const char *new_filename);
\r
185 /* Create a new query for 'database'.
\r
187 * Here, 'database' should be an open database, (see
\r
188 @@ -1095,7 +1102,8 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message);
\r
189 * for synchronizing maildir flag changes back to tags.
\r
192 -notmuch_message_tags_to_maildir_flags (notmuch_message_t *message);
\r
193 +notmuch_message_tags_to_maildir_flags (notmuch_mailstore_t *mailstore,
\r
194 + notmuch_message_t *message);
\r
196 /* Freeze the current state of 'message' within the database.
\r
198 diff --git a/notmuch-restore.c b/notmuch-restore.c
\r
199 index b382b7b..a0beab4 100644
\r
200 --- a/notmuch-restore.c
\r
201 +++ b/notmuch-restore.c
\r
202 @@ -25,6 +25,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
204 notmuch_config_t *config;
\r
205 notmuch_database_t *notmuch;
\r
206 + notmuch_mailstore_t *mailstore;
\r
207 notmuch_bool_t synchronize_flags;
\r
208 notmuch_bool_t accumulate = FALSE;
\r
209 char *input_file_name = NULL;
\r
210 @@ -40,7 +41,9 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
211 if (config == NULL)
\r
214 - notmuch = notmuch_database_open (notmuch_config_get_mailstore (config),
\r
215 + mailstore = notmuch_config_get_mailstore (config);
\r
217 + notmuch = notmuch_database_open (mailstore,
\r
218 notmuch_config_get_database_path (config),
\r
219 NOTMUCH_DATABASE_MODE_READ_WRITE);
\r
220 if (notmuch == NULL)
\r
221 @@ -170,7 +173,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
222 notmuch_message_thaw (message);
\r
224 if (synchronize_flags)
\r
225 - notmuch_message_tags_to_maildir_flags (message);
\r
226 + notmuch_message_tags_to_maildir_flags (mailstore, message);
\r
230 diff --git a/notmuch-tag.c b/notmuch-tag.c
\r
231 index 5e8d74a..0e0a7b4 100644
\r
232 --- a/notmuch-tag.c
\r
233 +++ b/notmuch-tag.c
\r
234 @@ -122,6 +122,7 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])
\r
235 notmuch_query_t *query;
\r
236 notmuch_messages_t *messages;
\r
237 notmuch_message_t *message;
\r
238 + notmuch_mailstore_t *mailstore;
\r
239 struct sigaction action;
\r
240 notmuch_bool_t synchronize_flags;
\r
242 @@ -187,7 +188,9 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])
\r
243 if (config == NULL)
\r
246 - notmuch = notmuch_database_open (notmuch_config_get_mailstore (config),
\r
247 + mailstore = notmuch_config_get_mailstore (config);
\r
249 + notmuch = notmuch_database_open (mailstore,
\r
250 notmuch_config_get_database_path (config),
\r
251 NOTMUCH_DATABASE_MODE_READ_WRITE);
\r
252 if (notmuch == NULL)
\r
253 @@ -222,7 +225,7 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])
\r
254 notmuch_message_thaw (message);
\r
256 if (synchronize_flags)
\r
257 - notmuch_message_tags_to_maildir_flags (message);
\r
258 + notmuch_message_tags_to_maildir_flags (mailstore, message);
\r
260 notmuch_message_destroy (message);
\r