1 Return-Path: <tomi.ollila@iki.fi>
\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 EB815429E2F
\r
6 for <notmuch@notmuchmail.org>; Tue, 13 Sep 2011 14:32:30 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\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 fRRhN2pY-Px9 for <notmuch@notmuchmail.org>;
\r
16 Tue, 13 Sep 2011 14:32:28 -0700 (PDT)
\r
17 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])
\r
18 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 8AB1B429E29
\r
21 for <notmuch@notmuchmail.org>; Tue, 13 Sep 2011 14:32:26 -0700 (PDT)
\r
22 Received: from localhost6.localdomain6 (entry3.nixu.fi [193.209.237.21])
\r
23 by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id
\r
24 p8DLW8G4022252; Wed, 14 Sep 2011 00:32:18 +0300
\r
25 From: tomi.ollila@iki.fi
\r
26 To: notmuch@notmuchmail.org
\r
27 Subject: [PATCH 3/3] added support for user-specified directories to exclude
\r
28 Date: Wed, 14 Sep 2011 00:32:04 +0300
\r
29 Message-Id: <1315949524-4948-4-git-send-email-tomi.ollila@iki.fi>
\r
30 X-Mailer: git-send-email 1.7.3.4
\r
31 In-Reply-To: <1315949524-4948-1-git-send-email-tomi.ollila@iki.fi>
\r
32 References: <1315949524-4948-1-git-send-email-tomi.ollila@iki.fi>
\r
33 Cc: Tomi Ollila <tomi.ollila@iki.fi>
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.13
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Tue, 13 Sep 2011 21:32:31 -0000
\r
48 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
50 A new configuration key 'database.exclude' is used to determine
\r
51 which directories user wants not to be scanned for new mails.
\r
53 notmuch-client.h | 3 +++
\r
54 notmuch-config.c | 19 +++++++++++++++++++
\r
55 notmuch-new.c | 22 ++++++++++++++++++++--
\r
56 3 files changed, 42 insertions(+), 2 deletions(-)
\r
58 diff --git a/notmuch-client.h b/notmuch-client.h
\r
59 index b50cb38..503ac79 100644
\r
60 --- a/notmuch-client.h
\r
61 +++ b/notmuch-client.h
\r
62 @@ -197,6 +197,9 @@ void
\r
63 notmuch_config_set_database_path (notmuch_config_t *config,
\r
64 const char *database_path);
\r
67 +notmuch_config_get_database_exclude (notmuch_config_t *config,
\r
70 notmuch_config_get_user_name (notmuch_config_t *config);
\r
72 diff --git a/notmuch-config.c b/notmuch-config.c
\r
73 index 648639b..b628074 100644
\r
74 --- a/notmuch-config.c
\r
75 +++ b/notmuch-config.c
\r
76 @@ -88,6 +88,8 @@ struct _notmuch_config {
\r
79 char *database_path;
\r
80 + const char **database_exclude;
\r
81 + size_t database_exclude_length;
\r
83 char *user_primary_email;
\r
84 const char **user_other_email;
\r
85 @@ -282,6 +284,8 @@ notmuch_config_open (void *ctx,
\r
86 config->key_file = g_key_file_new ();
\r
88 config->database_path = NULL;
\r
89 + config->database_exclude = NULL;
\r
90 + config->database_exclude_length = 0;
\r
91 config->user_name = NULL;
\r
92 config->user_primary_email = NULL;
\r
93 config->user_other_email = NULL;
\r
94 @@ -502,6 +506,21 @@ notmuch_config_set_database_path (notmuch_config_t *config,
\r
95 config->database_path = NULL;
\r
99 +notmuch_config_get_database_exclude (notmuch_config_t *config,
\r
102 + if (config->database_exclude == NULL) {
\r
103 + config->database_exclude = notmuch_talloc_g_key_file_get_string_list(
\r
105 + config->key_file,
\r
106 + "database", "exclude",
\r
107 + &config->database_exclude_length, NULL);
\r
109 + *length = config->database_exclude_length;
\r
110 + return config->database_exclude;
\r
114 notmuch_config_get_user_name (notmuch_config_t *config)
\r
116 diff --git a/notmuch-new.c b/notmuch-new.c
\r
117 index 7d17793..36da15f 100644
\r
118 --- a/notmuch-new.c
\r
119 +++ b/notmuch-new.c
\r
120 @@ -38,6 +38,8 @@ typedef struct {
\r
122 const char **new_tags;
\r
123 size_t new_tags_length;
\r
124 + const char **database_exclude;
\r
125 + size_t database_exclude_length;
\r
128 int processed_files;
\r
129 @@ -293,6 +295,8 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
130 is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);
\r
132 for (i = 0; i < num_fs_entries; i++) {
\r
138 @@ -316,8 +320,6 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
139 * Also ignore the .notmuch directory and any "tmp" directory
\r
140 * that appears within a maildir.
\r
142 - /* XXX: Eventually we'll want more sophistication to let the
\r
143 - * user specify files to be ignored. */
\r
144 if (strcmp (entry->d_name, ".") == 0 ||
\r
145 strcmp (entry->d_name, "..") == 0 ||
\r
146 (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
\r
147 @@ -325,6 +327,12 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
151 + /* Ignore user-specified directories */
\r
152 + for (j = 0; j < state->database_exclude_length; j++)
\r
153 + if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
\r
155 + if (j < state->database_exclude_length)
\r
158 next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
\r
159 status = add_files_recursive (notmuch, next, state);
\r
160 @@ -357,11 +365,20 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
161 /* Pass 2: Scan for new files, removed files, and removed directories. */
\r
162 for (i = 0; i < num_fs_entries; i++)
\r
169 entry = fs_entries[i];
\r
171 + /* Ignore user-specified files & directories */
\r
172 + for (j = 0; j < state->database_exclude_length; j++)
\r
173 + if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
\r
175 + if (j < state->database_exclude_length)
\r
178 /* Check if we've walked past any names in db_files or
\r
179 * db_subdirs. If so, these have been deleted. */
\r
180 while (notmuch_filenames_valid (db_files) &&
\r
181 @@ -800,6 +817,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
184 add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
185 + add_files_state.database_exclude = notmuch_config_get_database_exclude (config, &add_files_state.database_exclude_length);
\r
186 add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
187 add_files_state.message_ids_to_sync = _filename_list_create (ctx);
\r
188 db_path = notmuch_config_get_database_path (config);
\r