Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / d2 / 7c13342fd0ed10c9af5ab0ae87313d0762c86c
1 Return-Path: <geocar-notmuch@internetconnection.net>\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 C6542431FBD\r
6         for <notmuch@notmuchmail.org>; Thu, 21 Jan 2010 12:16:56 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.001\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.001 tagged_above=-999 required=5\r
12         tests=[BAYES_50=0.001] autolearn=ham\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 gd4UzekXOLka for <notmuch@notmuchmail.org>;\r
16         Thu, 21 Jan 2010 12:16:56 -0800 (PST)\r
17 X-Greylist: delayed 400 seconds by postgrey-1.32 at olra;\r
18         Thu, 21 Jan 2010 12:16:55 PST\r
19 Received: from proxy.dmvnoc.com (proxy.dmvnoc.com [216.169.144.254])\r
20         by olra.theworths.org (Postfix) with ESMTP id E6EAC431FAE\r
21         for <notmuch@notmuchmail.org>; Thu, 21 Jan 2010 12:16:55 -0800 (PST)\r
22 Received: (qmail 11079 invoked from network); 21 Jan 2010 20:10:14 +0000\r
23 Received: from unknown (HELO ?192.168.1.19?) (192.168.1.19)\r
24         by mail.internetconnection.net with SMTP; 21 Jan 2010 20:10:14 +0000\r
25 From: Geo Carncross <geocar-notmuch@internetconnection.net>\r
26 To: notmuch@notmuchmail.org\r
27 Content-Type: multipart/mixed; boundary="=-M4CpZ46nwdpaYw2E2ppA"\r
28 Date: Thu, 21 Jan 2010 15:10:18 -0500\r
29 Message-ID: <1264104618.3941.108.camel@dwarf>\r
30 Mime-Version: 1.0\r
31 X-Mailer: Evolution 2.28.1 \r
32 Subject: [notmuch] [PATCH] d_type fix\r
33 X-BeenThere: notmuch@notmuchmail.org\r
34 X-Mailman-Version: 2.1.13\r
35 Precedence: list\r
36 List-Id: "Use and development of the notmuch mail system."\r
37         <notmuch.notmuchmail.org>\r
38 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
39         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
41 List-Post: <mailto:notmuch@notmuchmail.org>\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
43 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
45 X-List-Received-Date: Thu, 21 Jan 2010 20:16:57 -0000\r
46 \r
47 \r
48 --=-M4CpZ46nwdpaYw2E2ppA\r
49 Content-Type: text/plain; charset="UTF-8"\r
50 Content-Transfer-Encoding: 7bit\r
51 \r
52 A review of notmuch-new.c shows three uses of ->d_type:\r
53 \r
54 Near line 153, in _entries_resemble_maildir() we can simply allow for\r
55 DT_UNKNOWN. This would fail if people have MH-style folders which have\r
56 three folders called "new" "cur" and "tmp", but that seems unlikely, in\r
57 which case the "tmp" folder would simply not be scanned.\r
58 \r
59 Near line 273 in add_files_recursive() we have another check. If\r
60 DT_UNKNOWN, we fall through, then add_files_recursive() does a stat\r
61 almost immediately, returning with success if the path isn't a\r
62 directory.\r
63 \r
64 Thus, the fallback is already written.\r
65 \r
66 Finally, near line 343, in add_files_recursive() (a long function) we\r
67 have another check. Here we can simply treat DT_UNKNOWN as DT_LNK, since\r
68 the logic for the stat() results are the same.\r
69 \r
70 Attached is a patch which was tested with reiserfs. It should also work\r
71 with xfs.\r
72 \r
73 \r
74 \r
75 --=-M4CpZ46nwdpaYw2E2ppA\r
76 Content-Disposition: attachment; filename="notmuch_new_d_type_fix.patch"\r
77 Content-Type: text/x-patch; name="notmuch_new_d_type_fix.patch";\r
78  charset="UTF-8"\r
79 Content-Transfer-Encoding: 7bit\r
80 \r
81 diff --git a/notmuch-new.c b/notmuch-new.c\r
82 index b740ee2..3e6b96a 100644\r
83 --- a/notmuch-new.c\r
84 +++ b/notmuch-new.c\r
85 @@ -153,7 +153,7 @@ _entries_resemble_maildir (struct dirent **entries, int count)\r
86      int i, found = 0;\r
87  \r
88      for (i = 0; i < count; i++) {\r
89 -       if (entries[i]->d_type != DT_DIR)\r
90 +       if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN)\r
91             continue;\r
92  \r
93         if (strcmp(entries[i]->d_name, "new") == 0 ||\r
94 @@ -273,7 +273,8 @@ add_files_recursive (notmuch_database_t *notmuch,\r
95  \r
96         entry = fs_entries[i];\r
97  \r
98 -       if (entry->d_type != DT_DIR && entry->d_type != DT_LNK)\r
99 +       if (entry->d_type != DT_DIR && entry->d_type != DT_LNK\r
100 +                       && entry->d_type != DT_UNKNOWN)\r
101             continue;\r
102  \r
103         /* Ignore special directories to avoid infinite recursion.\r
104 @@ -343,7 +344,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
105  \r
106         /* If we're looking at a symlink, we only want to add it if it\r
107          * links to a regular file, (and not to a directory, say). */\r
108 -       if (entry->d_type == DT_LNK) {\r
109 +       if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {\r
110             int err;\r
111  \r
112             next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);\r
113 \r
114 --=-M4CpZ46nwdpaYw2E2ppA--\r
115 \r