1 Return-Path: <jani@nikula.org>
\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 B27A0431FB6
\r
6 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 05:11:41 -0800 (PST)
\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 IWrAtt-EgIP6 for <notmuch@notmuchmail.org>;
\r
16 Thu, 26 Jan 2012 05:11:40 -0800 (PST)
\r
17 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com
\r
18 [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id B5E32431FAE
\r
21 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 05:11:40 -0800 (PST)
\r
22 Received: by qcpx40 with SMTP id x40so323872qcp.26
\r
23 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 05:11:40 -0800 (PST)
\r
24 Received: by 10.229.75.152 with SMTP id y24mr673466qcj.65.1327583500205;
\r
25 Thu, 26 Jan 2012 05:11:40 -0800 (PST)
\r
26 Received: from localhost (nikula.org. [92.243.24.172])
\r
27 by mx.google.com with ESMTPS id g3sm8476132qap.2.2012.01.26.05.11.38
\r
28 (version=SSLv3 cipher=OTHER); Thu, 26 Jan 2012 05:11:39 -0800 (PST)
\r
29 From: Jani Nikula <jani@nikula.org>
\r
30 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org
\r
31 Subject: Re: [PATCH 2/2] added support for user-specified directories to
\r
33 In-Reply-To: <1327572718-13411-2-git-send-email-tomi.ollila@iki.fi>
\r
34 References: <8762g0sj6f.fsf@praet.org>
\r
35 <1327572718-13411-1-git-send-email-tomi.ollila@iki.fi>
\r
36 <1327572718-13411-2-git-send-email-tomi.ollila@iki.fi>
\r
37 User-Agent: Notmuch/0.10.2+187~g43d4f26 (http://notmuchmail.org) Emacs/23.1.1
\r
39 Date: Thu, 26 Jan 2012 13:11:36 +0000
\r
40 Message-ID: <87pqe6ip6f.fsf@nikula.org>
\r
42 Content-Type: text/plain; charset=us-ascii
\r
43 Cc: Tomi Ollila <tomi.ollila@iki.fi>
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Thu, 26 Jan 2012 13:11:41 -0000
\r
58 On Thu, 26 Jan 2012 12:11:58 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
\r
59 > A new configuration key 'database.exclude' is used to determine
\r
60 > which directories user wants not to be scanned for new mails.
\r
64 > Notes (from 2011-09-13):
\r
66 > 1) Currently the comments for newly created configuration file are not
\r
67 > updated, so for not this is 'undocumented feature'. Should there be an
\r
68 > empty configuration line as a placeholder ... ?
\r
70 > 2) Whenever some already existing directory is added to the exclude list
\r
71 > and the parent directory timestamp has not changed, notmuch new will not
\r
72 > notice the directory has gone (as it still is there), user needs to 'touch'
\r
73 > the parent directory before next 'notmuch new' no make notmuch notice.
\r
75 > 2012-01-26: could notmuch track mtime of the configuration file and if
\r
76 > that changes, ignore mail directory timestamps ?
\r
78 > 3) count_files() function is not touched. The functionality there has fallen
\r
79 > behind of add_files_recursive (maildir+tmp check and following symlinks).
\r
80 > The question there should it be updated, or attempted to merge with
\r
81 > add_files (as the comment says). count_files() is only called at the beginning
\r
82 > when database is not yet initialised.
\r
84 > notmuch-client.h | 3 +++
\r
85 > notmuch-config.c | 13 +++++++++++++
\r
86 > notmuch-new.c | 22 ++++++++++++++++++++--
\r
87 > 3 files changed, 36 insertions(+), 2 deletions(-)
\r
89 > diff --git a/notmuch-client.h b/notmuch-client.h
\r
90 > index e0eb594..78460fc 100644
\r
91 > --- a/notmuch-client.h
\r
92 > +++ b/notmuch-client.h
\r
93 > @@ -219,6 +219,9 @@ void
\r
94 > notmuch_config_set_database_path (notmuch_config_t *config,
\r
95 > const char *database_path);
\r
98 > +notmuch_config_get_database_exclude (notmuch_config_t *config,
\r
99 > + size_t *length);
\r
101 > notmuch_config_get_user_name (notmuch_config_t *config);
\r
103 > diff --git a/notmuch-config.c b/notmuch-config.c
\r
104 > index a124e34..e236114 100644
\r
105 > --- a/notmuch-config.c
\r
106 > +++ b/notmuch-config.c
\r
107 > @@ -99,6 +99,8 @@ struct _notmuch_config {
\r
108 > GKeyFile *key_file;
\r
110 > char *database_path;
\r
111 > + const char **database_exclude;
\r
112 > + size_t database_exclude_length;
\r
114 > char *user_primary_email;
\r
115 > const char **user_other_email;
\r
116 > @@ -258,6 +260,8 @@ notmuch_config_open (void *ctx,
\r
117 > config->key_file = g_key_file_new ();
\r
119 > config->database_path = NULL;
\r
120 > + config->database_exclude = NULL;
\r
121 > + config->database_exclude_length = 0;
\r
122 > config->user_name = NULL;
\r
123 > config->user_primary_email = NULL;
\r
124 > config->user_other_email = NULL;
\r
125 > @@ -537,6 +541,15 @@ notmuch_config_set_database_path (notmuch_config_t *config,
\r
126 > config->database_path = NULL;
\r
130 > +notmuch_config_get_database_exclude (notmuch_config_t *config,
\r
131 > + size_t *length)
\r
133 > + return _config_get_list (config, "database", "exclude",
\r
134 > + &(config->database_exclude),
\r
135 > + &(config->database_exclude_length), length);
\r
139 > notmuch_config_get_user_name (notmuch_config_t *config)
\r
141 > diff --git a/notmuch-new.c b/notmuch-new.c
\r
142 > index a569a54..d607f5b 100644
\r
143 > --- a/notmuch-new.c
\r
144 > +++ b/notmuch-new.c
\r
145 > @@ -39,6 +39,8 @@ typedef struct {
\r
147 > const char **new_tags;
\r
148 > size_t new_tags_length;
\r
149 > + const char **database_exclude;
\r
150 > + size_t database_exclude_length;
\r
153 > int processed_files;
\r
154 > @@ -300,6 +302,8 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
155 > is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);
\r
157 > for (i = 0; i < num_fs_entries; i++) {
\r
163 > @@ -323,8 +327,6 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
164 > * Also ignore the .notmuch directory and any "tmp" directory
\r
165 > * that appears within a maildir.
\r
167 > - /* XXX: Eventually we'll want more sophistication to let the
\r
168 > - * user specify files to be ignored. */
\r
169 > if (strcmp (entry->d_name, ".") == 0 ||
\r
170 > strcmp (entry->d_name, "..") == 0 ||
\r
171 > (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
\r
172 > @@ -332,6 +334,12 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
176 > + /* Ignore user-specified directories */
\r
177 > + for (j = 0; j < state->database_exclude_length; j++)
\r
178 > + if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
\r
180 > + if (j < state->database_exclude_length)
\r
183 How about wrapping that in a function you can use here and below?
\r
185 if (user_wants_this_excluded (...))
\r
188 Please also have a look at id:"87pqecylon.fsf@nikula.org" and the
\r
189 patches Austin posted. "Auto ignore"?
\r
195 > next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
\r
196 > status = add_files_recursive (notmuch, next, state);
\r
197 > @@ -364,11 +372,20 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
198 > /* Pass 2: Scan for new files, removed files, and removed directories. */
\r
199 > for (i = 0; i < num_fs_entries; i++)
\r
206 > entry = fs_entries[i];
\r
208 > + /* Ignore user-specified files & directories */
\r
209 > + for (j = 0; j < state->database_exclude_length; j++)
\r
210 > + if (strcmp(entry->d_name, state->database_exclude[j]) == 0)
\r
212 > + if (j < state->database_exclude_length)
\r
215 > /* Check if we've walked past any names in db_files or
\r
216 > * db_subdirs. If so, these have been deleted. */
\r
217 > while (notmuch_filenames_valid (db_files) &&
\r
218 > @@ -837,6 +854,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
\r
221 > add_files_state.new_tags = notmuch_config_get_new_tags (config, &add_files_state.new_tags_length);
\r
222 > + add_files_state.database_exclude = notmuch_config_get_database_exclude (config, &add_files_state.database_exclude_length);
\r
223 > add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
224 > db_path = notmuch_config_get_database_path (config);
\r
229 > _______________________________________________
\r
230 > notmuch mailing list
\r
231 > notmuch@notmuchmail.org
\r
232 > http://notmuchmail.org/mailman/listinfo/notmuch
\r