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 C8993429E2B
\r
6 for <notmuch@notmuchmail.org>; Sat, 11 Jun 2011 13:07:16 -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 oqxs4Q8xQ7B6 for <notmuch@notmuchmail.org>;
\r
16 Sat, 11 Jun 2011 13:07:16 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 20047431FB6
\r
20 for <notmuch@notmuchmail.org>; Sat, 11 Jun 2011 13:07:16 -0700 (PDT)
\r
21 X-AuditID: 12074423-b7ce8ae000000a29-a1-4df3caee0342
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 8F.55.02601.EEAC3FD4; Sat, 11 Jun 2011 16:07:10 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id p5BK7FFM030040;
\r
27 Sat, 11 Jun 2011 16:07:15 -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 p5BK7ELE006044
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sat, 11 Jun 2011 16:07:15 -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 1QVUSg-0000IY-CZ; Sat, 11 Jun 2011 16:07:14 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 13/17] new: Cleanup. Put removed/renamed message count in
\r
42 Date: Sat, 11 Jun 2011 16:04:39 -0400
\r
43 Message-Id: <1307822683-848-14-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.5.1
\r
45 In-Reply-To: <1307822683-848-1-git-send-email-amdragon@mit.edu>
\r
46 References: <87ei34rnc5.fsf@yoom.home.cworth.org>
\r
47 <1307822683-848-1-git-send-email-amdragon@mit.edu>
\r
48 X-Brightmail-Tracker:
\r
49 H4sIAAAAAAAAA+NgFjrMIsWRmVeSWpSXmKPExsUixG6nrvvu1Gdfg4lnTC2u35zJ7MDo8WzV
\r
50 LeYAxigum5TUnMyy1CJ9uwSujFt31jIV3FGqOPbsAWMD4z7pLkZODgkBE4l9N6eyQdhiEhfu
\r
51 rQezhQT2MUrceSTaxcgFZG9glNj/YyYrhHOfSeL7v21QVfMZJebPlwex2QQ0JLbtX84IYosI
\r
52 SEvsvDsbqIGDg1lATeJPlwpIWFggVuLatz1MIDaLgKrEv0372UFsXgF7ibknj7FCHKEgceXK
\r
53 PBYQmxMoPu/gVRaIVWkSS27tZp/AyL+AkWEVo2xKbpVubmJmTnFqsm5xcmJeXmqRrplebmaJ
\r
54 XmpK6SZGcMi4KO9g/HNQ6RCjAAejEg+v4trPvkKsiWXFlbmHGCU5mJREeXVOAIX4kvJTKjMS
\r
55 izPii0pzUosPMUpwMCuJ8K5v/+QrxJuSWFmVWpQPk5LmYFES550rqe4rJJCeWJKanZpakFoE
\r
56 k5Xh4FCS4JUExoaQYFFqempFWmZOCUKaiYMTZDgP0PCjJ4FqeIsLEnOLM9Mh8qcYjTkeb9h0
\r
57 iJGjfTOQFGLJy89LlRLnVQcZJwBSmlGaBzcNFvevGMWBnhPm/QEykAeYMuDmvQJaxQS0SqAU
\r
58 bFVJIkJKqoFRtOHxgY9ZvoLBOxbKcBvKKJZP3FDpGbDxe5a9gEWTzB/noPPCqXN4rmvIPvtQ
\r
59 tm1S3KKKl5GWyQek7RzePfM9F70n4eVx9Yyv+hmst87uveBt01SveOEtM8sied8nbk5rZD4Y
\r
60 LdJ+sOjX7mDXX9eXXuEKcNUxm3Fw2lzTlU8ipCfUmt/+Gq+sxFKckWioxVxUnAgAIqG+ytYC AAA=
\r
61 Cc: Austin Clements <amdragon@mit.edu>
\r
62 X-BeenThere: notmuch@notmuchmail.org
\r
63 X-Mailman-Version: 2.1.13
\r
65 List-Id: "Use and development of the notmuch mail system."
\r
66 <notmuch.notmuchmail.org>
\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
70 List-Post: <mailto:notmuch@notmuchmail.org>
\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
73 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
74 X-List-Received-Date: Sat, 11 Jun 2011 20:07:17 -0000
\r
76 Previously, pointers to these variables were passed around
\r
77 individually. This was okay when only one function needed them, but
\r
78 we're about to need them in a few more places.
\r
80 notmuch-new.c | 36 ++++++++++++++++--------------------
\r
81 1 files changed, 16 insertions(+), 20 deletions(-)
\r
83 diff --git a/notmuch-new.c b/notmuch-new.c
\r
84 index d1bea55..cdc8a1c 100644
\r
87 @@ -42,7 +42,7 @@ typedef struct {
\r
90 int processed_files;
\r
91 - int added_messages;
\r
92 + int added_messages, removed_messages, renamed_messages;
\r
93 struct timeval tv_start;
\r
95 _filename_list_t *removed_files;
\r
96 @@ -702,8 +702,7 @@ static void
\r
97 _remove_directory (void *ctx,
\r
98 notmuch_database_t *notmuch,
\r
100 - int *renamed_files,
\r
101 - int *removed_files)
\r
102 + add_files_state_t *add_files_state)
\r
104 notmuch_directory_t *directory;
\r
105 notmuch_filenames_t *files, *subdirs;
\r
106 @@ -720,9 +719,9 @@ _remove_directory (void *ctx,
\r
107 notmuch_filenames_get (files));
\r
108 status = notmuch_database_remove_message (notmuch, absolute);
\r
109 if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID)
\r
110 - *renamed_files = *renamed_files + 1;
\r
111 + add_files_state->renamed_messages++;
\r
113 - *removed_files = *removed_files + 1;
\r
114 + add_files_state->removed_messages++;
\r
115 talloc_free (absolute);
\r
118 @@ -732,7 +731,7 @@ _remove_directory (void *ctx,
\r
120 absolute = talloc_asprintf (ctx, "%s/%s", path,
\r
121 notmuch_filenames_get (subdirs));
\r
122 - _remove_directory (ctx, notmuch, absolute, renamed_files, removed_files);
\r
123 + _remove_directory (ctx, notmuch, absolute, add_files_state);
\r
124 talloc_free (absolute);
\r
127 @@ -753,7 +752,6 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
128 char *dot_notmuch_path;
\r
129 struct sigaction action;
\r
130 _filename_node_t *f;
\r
131 - int renamed_files, removed_files;
\r
132 notmuch_status_t status;
\r
134 notmuch_bool_t timer_is_active = FALSE;
\r
135 @@ -826,6 +824,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
137 add_files_state.processed_files = 0;
\r
138 add_files_state.added_messages = 0;
\r
139 + add_files_state.removed_messages = add_files_state.renamed_messages = 0;
\r
140 gettimeofday (&add_files_state.tv_start, NULL);
\r
142 add_files_state.removed_files = _filename_list_create (ctx);
\r
143 @@ -840,27 +839,24 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
145 ret = add_files (notmuch, db_path, &add_files_state);
\r
147 - removed_files = 0;
\r
148 - renamed_files = 0;
\r
149 gettimeofday (&tv_start, NULL);
\r
150 for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) {
\r
151 status = notmuch_database_remove_message (notmuch, f->filename);
\r
152 if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID)
\r
154 + add_files_state.renamed_messages++;
\r
157 + add_files_state.removed_messages++;
\r
158 if (do_print_progress) {
\r
159 do_print_progress = 0;
\r
160 generic_print_progress ("Cleaned up", "messages",
\r
161 - tv_start, removed_files + renamed_files,
\r
162 + tv_start, add_files_state.removed_messages + add_files_state.renamed_messages,
\r
163 add_files_state.removed_files->count);
\r
167 gettimeofday (&tv_start, NULL);
\r
168 for (f = add_files_state.removed_directories->head, i = 0; f && !interrupted; f = f->next, i++) {
\r
169 - _remove_directory (ctx, notmuch, f->filename,
\r
170 - &renamed_files, &removed_files);
\r
171 + _remove_directory (ctx, notmuch, f->filename, &add_files_state);
\r
172 if (do_print_progress) {
\r
173 do_print_progress = 0;
\r
174 generic_print_progress ("Cleaned up", "directories",
\r
175 @@ -937,16 +933,16 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
176 printf ("No new mail.");
\r
179 - if (removed_files) {
\r
180 + if (add_files_state.removed_messages) {
\r
181 printf (" Removed %d %s.",
\r
183 - removed_files == 1 ? "message" : "messages");
\r
184 + add_files_state.removed_messages,
\r
185 + add_files_state.removed_messages == 1 ? "message" : "messages");
\r
188 - if (renamed_files) {
\r
189 + if (add_files_state.renamed_messages) {
\r
190 printf (" Detected %d file %s.",
\r
192 - renamed_files == 1 ? "rename" : "renames");
\r
193 + add_files_state.renamed_messages,
\r
194 + add_files_state.renamed_messages == 1 ? "rename" : "renames");
\r