1 Return-Path: <djcb@djcbsoftware.nl>
\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 03BAF431FBC
\r
6 for <notmuch@notmuchmail.org>; Sat, 12 Dec 2009 08:46:10 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id TR2VLImoolbx for <notmuch@notmuchmail.org>;
\r
11 Sat, 12 Dec 2009 08:46:08 -0800 (PST)
\r
12 Received: from gw01.mail.saunalahti.fi (gw01.mail.saunalahti.fi
\r
14 by olra.theworths.org (Postfix) with ESMTP id 99CB8431FAE
\r
15 for <notmuch@notmuchmail.org>; Sat, 12 Dec 2009 08:46:08 -0800 (PST)
\r
16 Received: from djcbsoftware.nl (a88-112-254-208.elisa-laajakaista.fi
\r
18 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by gw01.mail.saunalahti.fi (Postfix) with ESMTP id 4A48F1514B5;
\r
21 Sat, 12 Dec 2009 18:46:05 +0200 (EET)
\r
22 Received: from cthulhu.mindcrime.djcbsoftware.nl (localhost [127.0.0.1])
\r
23 by djcbsoftware.nl (Postfix) with ESMTP id 502EB39C0D8;
\r
24 Sat, 12 Dec 2009 18:46:03 +0200 (EET)
\r
25 Date: Sat, 12 Dec 2009 18:45:49 +0200
\r
26 Message-ID: <87my1ocf9e.wl%djcb@djcbsoftware.nl>
\r
27 From: Dirk-Jan C. Binnema <djcb.bulk@gmail.com>
\r
28 To: David Maus <maus.david@gmail.com>
\r
29 In-Reply-To: <874onwfizh.wl%maus.david@gmail.com>
\r
30 References: <87r5r0ctl3.wl%djcb@djcbsoftware.nl>
\r
31 <874onwfizh.wl%maus.david@gmail.com>
\r
32 Mail-Reply-To: djcb@djcbsoftware.nl
\r
33 User-Agent: Wanderlust/2.15.6 (Almost Unreal) Emacs/23.1 Mule/6.0
\r
35 Organization: DJCBSoftware
\r
36 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka")
\r
37 Content-Type: text/plain; charset=US-ASCII
\r
38 Cc: "notmuch@notmuchmail org" <notmuch@notmuchmail.org>
\r
39 Subject: Re: [notmuch] Subject: [PATCH] update the check whether a dir
\r
40 entry should be ignored.
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.12
\r
44 Reply-To: djcb@djcbsoftware.nl
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Sat, 12 Dec 2009 16:46:10 -0000
\r
58 >>>>> "DM" == David Maus <maus.david@gmail.com> writes:
\r
60 >> There is one maybe controversial change, namely that it ignores all
\r
61 >> dot-dirs; this works fine for .notmuch and .nnmaildir (gnus), but maybe
\r
62 >> there is some valid use case for having mail in dot-dirs. Maybe one of
\r
63 >> the IMAP-servers does this? Not sure. Anyway, I can change that part.
\r
65 DM> Yes, ignore dot-dirs completely is not a good idea as the "." is a
\r
66 DM> common separator for mailbox hierarchies on imap servers. Dovecot uses
\r
67 DM> it by default, Courier too.
\r
69 Thanks. I was suspecting something like that. Attached, updated patch that
\r
70 also updates the counting part.
\r
73 notmuch-new.c | 75 ++++++++++++++++++++++++++++++++++++++-------------------
\r
74 1 files changed, 50 insertions(+), 25 deletions(-)
\r
76 diff --git a/notmuch-new.c b/notmuch-new.c
\r
77 index 9d20616..411e084 100644
\r
80 @@ -109,6 +109,44 @@ is_maildir (struct dirent **entries, int count)
\r
86 +ignore_dir_entry (const char* path, struct dirent *entry)
\r
88 + char noindex[4096]; /* any path will fit */
\r
90 + /* ignore everything starting with a dot; this covers hidden
\r
91 + * files, as well as special dir (. and ..), but also things like
\r
92 + * gnus .nnmaildir or .notmuch */
\r
94 + /* special handling for dot-dirs */
\r
95 + if (entry->d_name[0] == '.') {
\r
97 + /* ignore '.' and '..' */
\r
98 + if (entry->d_name[1] == '\0' ||
\r
99 + (entry->d_name[1] == '.' && entry->d_name[2] == '\0'))
\r
102 + if (entry->d_name[1] == 'n') { /* optimization */
\r
103 + /* ignore notmuch, gnus special dirs (or such-named files) */
\r
104 + if (strcmp (entry->d_name, ".notmuch") == 0 ||
\r
105 + strcmp (entry->d_name, ".nnmaildir") == 0)
\r
110 + /* we also check if dir contains a file called '.noindex'; if so,
\r
111 + * we ignore this directory; alloca would be suitable here, if not
\r
112 + * for the portability. */
\r
113 + snprintf (noindex, sizeof(noindex), "%s/%s/.noindex", path, entry->d_name);
\r
114 + if (access (noindex, F_OK) == 0)
\r
117 + return 0; /* don't ignore */
\r
122 /* Examine 'path' recursively as follows:
\r
124 * o Ask the filesystem for the mtime of 'path' (path_mtime)
\r
125 @@ -181,21 +219,17 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
126 if (path_mtime <= path_dbtime && entry->d_type == DT_REG)
\r
129 - /* Ignore special directories to avoid infinite recursion.
\r
130 - * Also ignore the .notmuch directory.
\r
132 - /* XXX: Eventually we'll want more sophistication to let the
\r
133 - * user specify files to be ignored. */
\r
134 - if (strcmp (entry->d_name, ".") == 0 ||
\r
135 - strcmp (entry->d_name, "..") == 0 ||
\r
136 - (entry->d_type == DT_DIR &&
\r
137 - (strcmp (entry->d_name, "tmp") == 0) &&
\r
138 - is_maildir (namelist, num_entries)) ||
\r
139 - strcmp (entry->d_name, ".notmuch") ==0)
\r
144 + /* ignore tmp Maildirs, for obvious reasons */
\r
145 + if (entry->d_type == DT_DIR &&
\r
146 + (strcmp (entry->d_name, "tmp") == 0) &&
\r
147 + is_maildir (namelist, num_entries))
\r
150 + /* ignore special directories and files */
\r
151 + if (ignore_dir_entry (path, entry))
\r
154 next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
\r
156 if (stat (next, st)) {
\r
157 @@ -394,18 +428,9 @@ count_files (const char *path, int *count)
\r
159 entry= namelist[i++];
\r
161 - /* Ignore special directories to avoid infinite recursion.
\r
162 - * Also ignore the .notmuch directory.
\r
164 - /* XXX: Eventually we'll want more sophistication to let the
\r
165 - * user specify files to be ignored. */
\r
166 - if (strcmp (entry->d_name, ".") == 0 ||
\r
167 - strcmp (entry->d_name, "..") == 0 ||
\r
168 - strcmp (entry->d_name, ".notmuch") == 0)
\r
170 + if (ignore_dir_entry (path, entry))
\r
175 if (asprintf (&next, "%s/%s", path, entry->d_name) == -1) {
\r
177 fprintf (stderr, "Error descending from %s to %s: Out of memory\n",
\r