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 B82C5431FBC
\r
6 for <notmuch@notmuchmail.org>; Sat, 12 Dec 2009 04:01:00 -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 n263XsGBQLYN for <notmuch@notmuchmail.org>;
\r
11 Sat, 12 Dec 2009 04:01:00 -0800 (PST)
\r
12 Received: from gw03.mail.saunalahti.fi (gw03.mail.saunalahti.fi
\r
14 by olra.theworths.org (Postfix) with ESMTP id A7880431FAE
\r
15 for <notmuch@notmuchmail.org>; Sat, 12 Dec 2009 04:00:59 -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 gw03.mail.saunalahti.fi (Postfix) with ESMTP id 54E2F2165C2
\r
21 for <notmuch@notmuchmail.org>; Sat, 12 Dec 2009 14:00:53 +0200 (EET)
\r
22 Received: from cthulhu.mindcrime.djcbsoftware.nl (localhost [127.0.0.1])
\r
23 by djcbsoftware.nl (Postfix) with ESMTP id AF77439C0D8
\r
24 for <notmuch@notmuchmail.org>; Sat, 12 Dec 2009 13:36:24 +0200 (EET)
\r
25 Date: Sat, 12 Dec 2009 13:36:24 +0200
\r
26 Message-ID: <87r5r0ctl3.wl%djcb@djcbsoftware.nl>
\r
27 From: Dirk-Jan C. Binnema <djcb.bulk@gmail.com>
\r
28 To: "notmuch@notmuchmail org" <notmuch@notmuchmail.org>
\r
29 Mail-Reply-To: djcb@djcbsoftware.nl
\r
30 User-Agent: Wanderlust/2.15.6 (Almost Unreal) Emacs/23.1 Mule/6.0
\r
32 Organization: DJCBSoftware
\r
33 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka")
\r
34 Content-Type: text/plain; charset=US-ASCII
\r
35 Subject: [notmuch] Subject: [PATCH] update the check whether a dir entry
\r
37 X-BeenThere: notmuch@notmuchmail.org
\r
38 X-Mailman-Version: 2.1.12
\r
40 Reply-To: djcb@djcbsoftware.nl
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Sat, 12 Dec 2009 12:01:00 -0000
\r
54 This is a draft patch which hopefully improves the check whether a dir entry
\r
55 should be ignored for that. It adds one feature: if you put a file '.noindex'
\r
56 in a dir, the whole dir will be ignored for indexing. I find this very useful
\r
57 for removing e.g. folders with spam messages from the indexing.
\r
59 There is one maybe controversial change, namely that it ignores all dot-dirs;
\r
60 this works fine for .notmuch and .nnmaildir (gnus), but maybe there is some
\r
61 valid use case for having mail in dot-dirs. Maybe one of the IMAP-servers does
\r
62 this? Not sure. Anyway, I can change that part.
\r
64 If the overall approach is considered OK, I can make a new patch
\r
71 notmuch-new.c | 48 ++++++++++++++++++++++++++++++++++--------------
\r
72 1 files changed, 34 insertions(+), 14 deletions(-)
\r
74 diff --git a/notmuch-new.c b/notmuch-new.c
\r
75 index 9d20616..28f69bc 100644
\r
78 @@ -109,6 +109,30 @@ is_maildir (struct dirent **entries, int count)
\r
84 +ignore_dir_entry (const char* path, struct dirent *entry)
\r
86 + char noindex[4096]; /* any path will fit */
\r
88 + /* ignore everything starting with a dot; this covers hidden
\r
89 + * files, as well as special dir (. and ..), but also things like
\r
90 + * gnus .nnmaildir or .notmuch */
\r
91 + if (entry->d_name[0] == '.')
\r
94 + /* we also check if dir contains a file called '.noindex'; if so,
\r
95 + * we ignore this directory; alloca would be suitable here, if not
\r
96 + * for the portability. */
\r
97 + snprintf (noindex, sizeof(noindex), "%s/%s/.noindex", path, entry->d_name);
\r
98 + if (access (noindex, F_OK) == 0)
\r
101 + return 0; /* don't ignore */
\r
106 /* Examine 'path' recursively as follows:
\r
108 * o Ask the filesystem for the mtime of 'path' (path_mtime)
\r
109 @@ -181,21 +205,17 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
110 if (path_mtime <= path_dbtime && entry->d_type == DT_REG)
\r
113 - /* Ignore special directories to avoid infinite recursion.
\r
114 - * Also ignore the .notmuch directory.
\r
116 - /* XXX: Eventually we'll want more sophistication to let the
\r
117 - * user specify files to be ignored. */
\r
118 - if (strcmp (entry->d_name, ".") == 0 ||
\r
119 - strcmp (entry->d_name, "..") == 0 ||
\r
120 - (entry->d_type == DT_DIR &&
\r
121 - (strcmp (entry->d_name, "tmp") == 0) &&
\r
122 - is_maildir (namelist, num_entries)) ||
\r
123 - strcmp (entry->d_name, ".notmuch") ==0)
\r
128 + /* ignore tmp Maildirs, for obvious reasons */
\r
129 + if (entry->d_type == DT_DIR &&
\r
130 + (strcmp (entry->d_name, "tmp") == 0) &&
\r
131 + is_maildir (namelist, num_entries))
\r
134 + /* ignore special directories and files */
\r
135 + if (ignore_dir_entry (path, entry))
\r
138 next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
\r
140 if (stat (next, st)) {
\r