[PATCH] n_m_remove_property(msg, key, NULL) should removes all properties with key
[notmuch-archives.git] / 1b / ace28a1dc8555b1683dce51727190ac36dc9d8
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
13         [195.197.172.111])\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
17         [88.112.254.208])\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
31         (HANACHIRUSATO)\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
36         should be ignored.\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.12\r
39 Precedence: list\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
51 \r
52 Hi all,\r
53 \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
58 \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
63 \r
64 If the overall approach is considered OK, I can make a new patch\r
65 \r
66 Best wishes,\r
67 Dirk.\r
68 \r
69 \r
70 ---\r
71  notmuch-new.c |   48 ++++++++++++++++++++++++++++++++++--------------\r
72  1 files changed, 34 insertions(+), 14 deletions(-)\r
73 \r
74 diff --git a/notmuch-new.c b/notmuch-new.c\r
75 index 9d20616..28f69bc 100644\r
76 --- a/notmuch-new.c\r
77 +++ b/notmuch-new.c\r
78 @@ -109,6 +109,30 @@ is_maildir (struct dirent **entries, int count)\r
79      return 0;\r
80  }\r
81  \r
82 +\r
83 +static int\r
84 +ignore_dir_entry (const char* path, struct dirent *entry)\r
85 +{\r
86 +    char noindex[4096]; /* any path will fit */\r
87 +    \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
92 +       return 1;\r
93 +    \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
99 +       return 1;\r
100 +    \r
101 +    return 0; /* don't ignore */\r
102 +}\r
103 +\r
104 +    \r
105 +\r
106  /* Examine 'path' recursively as follows:\r
107   *\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
111             continue;\r
112  \r
113 -       /* Ignore special directories to avoid infinite recursion.\r
114 -        * Also ignore the .notmuch directory.\r
115 -        */\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
124 -       {\r
125 -           continue;\r
126 -       }\r
127  \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
132 +           continue;\r
133 +       \r
134 +       /* ignore special directories and files */\r
135 +       if (ignore_dir_entry (path, entry))\r
136 +           continue;\r
137 +       \r
138         next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);\r
139  \r
140         if (stat (next, st)) {\r
141 -- \r
142 1.6.3.3\r
143 \r