1 Return-Path: <too@guru.guru-group.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 2A01F431FAF
\r
6 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 02:12:02 -0800 (PST)
\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 gCHpRpXEEdF6 for <notmuch@notmuchmail.org>;
\r
16 Thu, 26 Jan 2012 02:12:01 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])
\r
18 by olra.theworths.org (Postfix) with ESMTP id CFADD431FAE
\r
19 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 02:12:00 -0800 (PST)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id C4F9D68057; Thu, 26 Jan 2012 12:12:01 +0200 (EET)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [PATCH 2/2] added support for user-specified directories to exclude
\r
25 Date: Thu, 26 Jan 2012 12:11:58 +0200
\r
26 Message-Id: <1327572718-13411-2-git-send-email-tomi.ollila@iki.fi>
\r
27 X-Mailer: git-send-email 1.7.6.1
\r
28 In-Reply-To: <1327572718-13411-1-git-send-email-tomi.ollila@iki.fi>
\r
29 References: <8762g0sj6f.fsf@praet.org>
\r
30 <1327572718-13411-1-git-send-email-tomi.ollila@iki.fi>
\r
31 Cc: Tomi Ollila <tomi.ollila@iki.fi>
\r
32 X-BeenThere: notmuch@notmuchmail.org
\r
33 X-Mailman-Version: 2.1.13
\r
35 List-Id: "Use and development of the notmuch mail system."
\r
36 <notmuch.notmuchmail.org>
\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
38 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
40 List-Post: <mailto:notmuch@notmuchmail.org>
\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
44 X-List-Received-Date: Thu, 26 Jan 2012 10:12:02 -0000
\r
46 A new configuration key 'database.exclude' is used to determine
\r
47 which directories user wants not to be scanned for new mails.
\r
51 Notes (from 2011-09-13):
\r
53 1) Currently the comments for newly created configuration file are not
\r
54 updated, so for not this is 'undocumented feature'. Should there be an
\r
55 empty configuration line as a placeholder ... ?
\r
57 2) Whenever some already existing directory is added to the exclude list
\r
58 and the parent directory timestamp has not changed, notmuch new will not
\r
59 notice the directory has gone (as it still is there), user needs to 'touch'
\r
60 the parent directory before next 'notmuch new' no make notmuch notice.
\r
62 2012-01-26: could notmuch track mtime of the configuration file and if
\r
63 that changes, ignore mail directory timestamps ?
\r
65 3) count_files() function is not touched. The functionality there has fallen
\r
66 behind of add_files_recursive (maildir+tmp check and following symlinks).
\r
67 The question there should it be updated, or attempted to merge with
\r
68 add_files (as the comment says). count_files() is only called at the beginning
\r
69 when database is not yet initialised.
\r
71 notmuch-client.h | 3 +++
\r
72 notmuch-config.c | 13 +++++++++++++
\r
73 notmuch-new.c | 22 ++++++++++++++++++++--
\r
74 3 files changed, 36 insertions(+), 2 deletions(-)
\r
76 diff --git a/notmuch-client.h b/notmuch-client.h
\r
77 index e0eb594..78460fc 100644
\r
78 --- a/notmuch-client.h
\r
79 +++ b/notmuch-client.h
\r
80 @@ -219,6 +219,9 @@ void
\r
81 notmuch_config_set_database_path (notmuch_config_t *config,
\r
82 const char *database_path);
\r
85 +notmuch_config_get_database_exclude (notmuch_config_t *config,
\r
88 notmuch_config_get_user_name (notmuch_config_t *config);
\r
90 diff --git a/notmuch-config.c b/notmuch-config.c
\r
91 index a124e34..e236114 100644
\r
92 --- a/notmuch-config.c
\r
93 +++ b/notmuch-config.c
\r
94 @@ -99,6 +99,8 @@ struct _notmuch_config {
\r
97 char *database_path;
\r
98 + const char **database_exclude;
\r
99 + size_t database_exclude_length;
\r
101 char *user_primary_email;
\r
102 const char **user_other_email;
\r
103 @@ -258,6 +260,8 @@ notmuch_config_open (void *ctx,
\r
104 config->key_file = g_key_file_new ();
\r
106 config->database_path = NULL;
\r
107 + config->database_exclude = NULL;
\r
108 + config->database_exclude_length = 0;
\r
109 config->user_name = NULL;
\r
110 config->user_primary_email = NULL;
\r
111 config->user_other_email = NULL;
\r
112 @@ -537,6 +541,15 @@ notmuch_config_set_database_path (notmuch_config_t *config,
\r
113 config->database_path = NULL;
\r
117 +notmuch_config_get_database_exclude (notmuch_config_t *config,
\r
120 + return _config_get_list (config, "database", "exclude",
\r
121 + &(config->database_exclude),
\r
122 + &(config->database_exclude_length), length);
\r
126 notmuch_config_get_user_name (notmuch_config_t *config)
\r
128 diff --git a/notmuch-new.c b/notmuch-new.c
\r
129 index a569a54..d607f5b 100644
\r
130 --- a/notmuch-new.c
\r
131 +++ b/notmuch-new.c
\r
132 @@ -39,6 +39,8 @@ typedef struct {
\r
134 const char **new_tags;
\r
135 size_t new_tags_length;
\r
136 + const char **database_exclude;
\r
137 + size_t database_exclude_length;
\r
140 int processed_files;
\r
141 @@ -300,6 +302,8 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
142 is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);
\r
144 for (i = 0; i < num_fs_entries; i++) {
\r
150 @@ -323,8 +327,6 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
151 * Also ignore the .notmuch directory and any "tmp" directory
\r
152 * that appears within a maildir.
\r
154 - /* XXX: Eventually we'll want more sophistication to let the
\r
155 - * user specify files to be ignored. */
\r
156 if (strcmp (entry->d_name, ".") == 0 ||
\r
157 strcmp (entry->d_name, "..") == 0 ||
\r
158 (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
\r
159 @@ -332,6 +334,12 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
163 + /* Ignore user-specified directories */
\r
164 + for (j = 0; j < state->database_exclude_length; j++)
\r
165 + if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
\r
167 + if (j < state->database_exclude_length)
\r
170 next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
\r
171 status = add_files_recursive (notmuch, next, state);
\r
172 @@ -364,11 +372,20 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
173 /* Pass 2: Scan for new files, removed files, and removed directories. */
\r
174 for (i = 0; i < num_fs_entries; i++)
\r
181 entry = fs_entries[i];
\r
183 + /* Ignore user-specified files & directories */
\r
184 + for (j = 0; j < state->database_exclude_length; j++)
\r
185 + if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
\r
187 + if (j < state->database_exclude_length)
\r
190 /* Check if we've walked past any names in db_files or
\r
191 * db_subdirs. If so, these have been deleted. */
\r
192 while (notmuch_filenames_valid (db_files) &&
\r
193 @@ -837,6 +854,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
196 add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
197 + add_files_state.database_exclude = notmuch_config_get_database_exclude (config, &add_files_state.database_exclude_length);
\r
198 add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
199 db_path = notmuch_config_get_database_path (config);
\r