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 A7939429E48
\r
6 for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:10:30 -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 w3ZrmvnjD5Zl for <notmuch@notmuchmail.org>;
\r
18 Wed, 15 Feb 2012 14:10:30 -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 D6AAB429E43 for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:10:29 -0800
\r
25 S|27febe0d6a4a25f7165855ffcf20f3e2c2e41321|d46bf90b1bccc1c6fd89498d004525ee
\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=1329343827; x=1329948627; l=4690;
\r
32 bh=1gAx2pb+B+LfzgRdy0uZzzlaHmY=; b=Ips66o/vU8UNdpRkj5ujg91
\r
33 Gwf/71hDPAEs+KnYN4QPKP1xRk8UntxS5oosR3wHhmm/S3fKJqvL0hD+gJgw4lKx
\r
34 brsuk0E/NvhnpIN0ZCdYitEMm1aKsU8nBOBwoMPpqNisuuZNai+vlPo6AGIYT/Sc
\r
35 aA8T+1iEmW0Gm06JlrMQ=
\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=Z3UCn4n21CxtwkaHSSJcYLmhaxTp9y4K3Vp+ApBPabX34eEe3eRn6
\r
39 x6krPyGTw/Pc8ShYI/z1WjDqcENBuczt3096jlbf5pR7RUnVXzvh8RUePmfJbxrw
\r
40 MxIBsB/fMrdZ/LsD2iBsQyk7QTa3jPMDguSlaiqEOoT2iOY5gKl+io=
\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:q1FM9tuK008835 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 q1FM9tuK008835
\r
52 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);
\r
53 Wed, 15 Feb 2012 17:10:19 -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 08/13] count_files and add_files shall be generic
\r
58 Date: Wed, 15 Feb 2012 17:02:01 -0500
\r
59 Message-Id: <1329343326-16410-9-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:10:30 -0000
\r
79 From: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
81 Rename current count_files and add_files to maildir_count_files and
\r
82 maildir_add_files. This allows the possibility, at least, of having
\r
85 Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
\r
87 notmuch-new.c | 62 +++++++++++++++++++++++++++++++++++++++++++++-----------
\r
88 1 files changed, 50 insertions(+), 12 deletions(-)
\r
90 diff --git a/notmuch-new.c b/notmuch-new.c
\r
91 index dbdfbb6..d30fba1 100644
\r
94 @@ -340,9 +340,9 @@ _add_message (add_files_state_t *state, notmuch_database_t *notmuch,
\r
95 * if fs_mtime isn't the current wall-clock time.
\r
97 static notmuch_status_t
\r
98 -add_files_recursive (notmuch_database_t *notmuch,
\r
100 - add_files_state_t *state)
\r
101 +maildir_add_files_recursive (notmuch_database_t *notmuch,
\r
102 + const char *path,
\r
103 + add_files_state_t *state)
\r
106 struct dirent *entry = NULL;
\r
107 @@ -449,7 +449,7 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
110 next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
\r
111 - status = add_files_recursive (notmuch, next, state);
\r
112 + status = maildir_add_files_recursive (notmuch, next, state);
\r
113 if (status && ret == NOTMUCH_STATUS_SUCCESS)
\r
115 talloc_free (next);
\r
116 @@ -663,13 +663,34 @@ stop_progress_printing_timer (void)
\r
117 sigaction (SIGALRM, &action, NULL);
\r
120 +static notmuch_status_t
\r
121 +maildir_add_files (notmuch_database_t *notmuch,
\r
122 + const char *path,
\r
123 + add_files_state_t *state);
\r
125 +/* Dispatch function to call the correct mailstore_add_files
\r
127 +static notmuch_status_t
\r
128 +add_files (notmuch_database_t *notmuch, notmuch_config_t *config,
\r
129 + add_files_state_t *state)
\r
131 + const char *path = notmuch_config_get_database_path (config);
\r
132 + if (strcmp (notmuch_config_get_database_type (config), "maildir") == 0)
\r
133 + return maildir_add_files (notmuch, path, state);
\r
135 + /* Default case */
\r
136 + fprintf (stderr, "Could not add files for mailstore %s: unknown mailstore\n",
\r
137 + notmuch_config_get_database_type (config));
\r
138 + /* FIXME: "invalid argument" error code would be nice */
\r
139 + return NOTMUCH_STATUS_FILE_ERROR;
\r
142 /* This is the top-level entry point for add_files. It does a couple
\r
143 * of error checks and then calls into the recursive function. */
\r
144 static notmuch_status_t
\r
145 -add_files (notmuch_database_t *notmuch,
\r
146 - const char *path,
\r
147 - add_files_state_t *state)
\r
148 +maildir_add_files (notmuch_database_t *notmuch,
\r
149 + const char *path,
\r
150 + add_files_state_t *state)
\r
152 notmuch_status_t status;
\r
154 @@ -685,11 +706,28 @@ add_files (notmuch_database_t *notmuch,
\r
155 return NOTMUCH_STATUS_FILE_ERROR;
\r
158 - status = add_files_recursive (notmuch, path, state);
\r
159 + status = maildir_add_files_recursive (notmuch, path, state);
\r
165 +maildir_count_files (const char *path, int *count);
\r
167 +/* Dispatch function to call the correct mailstore_count_files
\r
168 + * function. N.B. This function may get refactored into add_files! */
\r
170 +count_files (unused (notmuch_database_t *notmuch), notmuch_config_t *config, int *count)
\r
172 + if (strcmp (notmuch_config_get_database_type (config), "maildir") == 0) {
\r
173 + maildir_count_files (notmuch_config_get_database_path (config), count);
\r
177 + /* Eh, screw it, this function shouldn't even exist */
\r
181 /* XXX: This should be merged with the add_files function since it
\r
182 * shares a lot of logic with it. */
\r
183 /* Recursively count all regular files in path and all sub-directories
\r
184 @@ -697,7 +735,7 @@ add_files (notmuch_database_t *notmuch,
\r
185 * initialized to zero by the top-level caller before calling
\r
188 -count_files (const char *path, int *count)
\r
189 +maildir_count_files (const char *path, int *count)
\r
191 struct dirent *entry = NULL;
\r
193 @@ -746,7 +784,7 @@ count_files (const char *path, int *count)
\r
196 } else if (S_ISDIR (st.st_mode)) {
\r
197 - count_files (next, count);
\r
198 + maildir_count_files (next, count);
\r
202 @@ -905,7 +943,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
206 - count_files (db_path, &count);
\r
207 + count_files (notmuch, config, &count);
\r
211 @@ -962,7 +1000,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
212 timer_is_active = TRUE;
\r
215 - ret = add_files (notmuch, db_path, &add_files_state);
\r
216 + ret = add_files (notmuch, config, &add_files_state);
\r
218 gettimeofday (&tv_start, NULL);
\r
219 for (f = add_files_state.removed_files->head; f && !interrupted; f = f->next) {
\r