1 Return-Path: <amthrax@drake.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 84DD3429E2B
\r
6 for <notmuch@notmuchmail.org>; Sat, 11 Jun 2011 13:07:27 -0700 (PDT)
\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 OnsD6EdvPy4E for <notmuch@notmuchmail.org>;
\r
16 Sat, 11 Jun 2011 13:07:27 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id D6F46431FB6
\r
20 for <notmuch@notmuchmail.org>; Sat, 11 Jun 2011 13:07:26 -0700 (PDT)
\r
21 X-AuditID: 1209190e-b7c39ae000000a8c-b9-4df3caedecc7
\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\r
23 by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 09.7A.02700.DEAC3FD4; Sat, 11 Jun 2011 16:07:09 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id p5BK7QrI030878;
\r
27 Sat, 11 Jun 2011 16:07:26 -0400
\r
28 Received: from drake.mit.edu
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p5BK7PAn006058
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sat, 11 Jun 2011 16:07:26 -0400 (EDT)
\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.76)
\r
36 (envelope-from <amthrax@drake.mit.edu>)
\r
37 id 1QVUSr-0000Ie-69; Sat, 11 Jun 2011 16:07:25 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 15/17] new: Synchronize maildir flags eagerly.
\r
41 Date: Sat, 11 Jun 2011 16:04:41 -0400
\r
42 Message-Id: <1307822683-848-16-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.5.1
\r
44 In-Reply-To: <1307822683-848-1-git-send-email-amdragon@mit.edu>
\r
45 References: <87ei34rnc5.fsf@yoom.home.cworth.org>
\r
46 <1307822683-848-1-git-send-email-amdragon@mit.edu>
\r
47 X-Brightmail-Tracker:
\r
48 H4sIAAAAAAAAA+NgFtrPIsWRmVeSWpSXmKPExsUixG6novv21Gdfg4Y2MYvrN2cyOzB6PFt1
\r
49 izmAMYrLJiU1J7MstUjfLoEr48zlc4wFb+QrPs+cwtTA+EKyi5GTQ0LAROJk8xwmCFtM4sK9
\r
50 9WxdjFwcQgL7GCWmbpnGDOFsYJQ49nIqE4Rzn0libcd/KGc+o8TdfU3sIP1sAhoS2/YvZwSx
\r
51 RQSkJXbenc3axcjBwSygJvGnSwUkLCxgJ/F7xXdWEJtFQFXi+ff3YK28AvYSV+Z/YYU4Q0Hi
\r
52 ypV5LCA2J1B83sGrYLaQQJrEklu72Scw8i9gZFjFKJuSW6Wbm5iZU5yarFucnJiXl1qka6yX
\r
53 m1mil5pSuokRFDacknw7GL8eVDrEKMDBqMTDq7f2s68Qa2JZcWXuIUZJDiYlUV6dE0AhvqT8
\r
54 lMqMxOKM+KLSnNTiQ4wSHMxKIrzr2z/5CvGmJFZWpRblw6SkOViUxHlnSqr7CgmkJ5akZqem
\r
55 FqQWwWRlODiUJHglgfEhJFiUmp5akZaZU4KQZuLgBBnOAzT86EmgGt7igsTc4sx0iPwpRl2O
\r
56 xxs2HWIUYsnLz0uVEudVBxkkAFKUUZoHNwcW768YxYHeEub9ATKKB5gq4Ca9AlrCBLREoBRs
\r
57 SUkiQkqqgVFpQeikjU+ZOhm2/WibJ5Oxstvjzc6Zd5XOzNI6+3LaorW7rVUPPj2zZ8nXN24Z
\r
58 +ilnbfNecfPs3nztukXnXdfQ84lxSYbch5sSF9+dbhxY9vYEgzOv+PyWSr9p3mub9oS79ZxP
\r
59 axZ49e10Dk+EG9+N9yvfx9hOnrYvPkbJ63/zmaW2x9Jutz1XYinOSDTUYi4qTgQAUrt5ZdIC AAA=
\r
60 Cc: Austin Clements <amdragon@mit.edu>
\r
61 X-BeenThere: notmuch@notmuchmail.org
\r
62 X-Mailman-Version: 2.1.13
\r
64 List-Id: "Use and development of the notmuch mail system."
\r
65 <notmuch.notmuchmail.org>
\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
69 List-Post: <mailto:notmuch@notmuchmail.org>
\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
73 X-List-Received-Date: Sat, 11 Jun 2011 20:07:27 -0000
\r
75 Because flag synchronization is stateless, it can be performed at any
\r
76 time as long as it's guaranteed to be performed after any change to a
\r
77 message's filename list. Take advantage of this to synchronize tags
\r
78 immediately after a filename is added or removed.
\r
80 This does not yet make adding or removing a message atomic, but it is
\r
81 a big step toward atomicity because it reduces the window where the
\r
82 database tags are inconsistent from nearly the entire notmuch-new to
\r
83 just around when the message is added or removed.
\r
85 notmuch-new.c | 42 ++++++++----------------------------------
\r
86 1 files changed, 8 insertions(+), 34 deletions(-)
\r
88 diff --git a/notmuch-new.c b/notmuch-new.c
\r
89 index dc349f6..b24eb51 100644
\r
92 @@ -50,7 +50,6 @@ typedef struct {
\r
93 _filename_list_t *directory_mtimes;
\r
95 notmuch_bool_t synchronize_flags;
\r
96 - _filename_list_t *message_ids_to_sync;
\r
97 } add_files_state_t;
\r
99 static volatile sig_atomic_t do_print_progress = 0;
\r
100 @@ -443,11 +442,8 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
102 /* Non-fatal issues (go on to next file) */
\r
103 case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
\r
104 - /* Defer sync of maildir flags until after old filenames
\r
105 - * are removed in the case of a rename. */
\r
106 if (state->synchronize_flags == TRUE)
\r
107 - _filename_list_add (state->message_ids_to_sync,
\r
108 - notmuch_message_get_message_id (message));
\r
109 + notmuch_message_maildir_flags_to_tags (message);
\r
111 case NOTMUCH_STATUS_FILE_NOT_EMAIL:
\r
112 fprintf (stderr, "Note: Ignoring non-mail file: %s\n",
\r
113 @@ -703,11 +699,16 @@ remove_filename (notmuch_database_t *notmuch,
\r
114 add_files_state_t *add_files_state)
\r
116 notmuch_status_t status;
\r
117 + notmuch_message_t *message;
\r
118 + message = notmuch_database_find_message_by_filename (notmuch, path);
\r
119 status = notmuch_database_remove_message (notmuch, path);
\r
120 - if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID)
\r
121 + if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
\r
122 add_files_state->renamed_messages++;
\r
124 + if (add_files_state->synchronize_flags == TRUE)
\r
125 + notmuch_message_maildir_flags_to_tags (message);
\r
127 add_files_state->removed_messages++;
\r
128 + notmuch_message_destroy (message);
\r
132 @@ -782,7 +783,6 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
134 add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
135 add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
136 - add_files_state.message_ids_to_sync = _filename_list_create (ctx);
\r
137 db_path = notmuch_config_get_database_path (config);
\r
139 dot_notmuch_path = talloc_asprintf (ctx, "%s/%s", db_path, ".notmuch");
\r
140 @@ -883,32 +883,6 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
141 talloc_free (add_files_state.removed_directories);
\r
142 talloc_free (add_files_state.directory_mtimes);
\r
144 - /* Now that removals are done (hence the database is aware of all
\r
145 - * renames), we can synchronize maildir_flags to tags for all
\r
146 - * messages that had new filenames appear on this run. */
\r
147 - gettimeofday (&tv_start, NULL);
\r
148 - if (add_files_state.synchronize_flags) {
\r
149 - _filename_node_t *node;
\r
150 - notmuch_message_t *message;
\r
151 - for (node = add_files_state.message_ids_to_sync->head, i = 0;
\r
153 - node = node->next, i++)
\r
155 - message = notmuch_database_find_message (notmuch, node->filename);
\r
156 - notmuch_message_maildir_flags_to_tags (message);
\r
157 - notmuch_message_destroy (message);
\r
158 - if (do_print_progress) {
\r
159 - do_print_progress = 0;
\r
160 - generic_print_progress (
\r
161 - "Synchronized tags for", "messages",
\r
162 - tv_start, i, add_files_state.message_ids_to_sync->count);
\r
167 - talloc_free (add_files_state.message_ids_to_sync);
\r
168 - add_files_state.message_ids_to_sync = NULL;
\r
170 if (timer_is_active)
\r
171 stop_progress_printing_timer ();
\r