1 Return-Path: <stewart@flamingspork.com>
\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 B0EF3431FBC
\r
6 for <notmuch@notmuchmail.org>; Tue, 17 Nov 2009 18:22:25 -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 o-waKGygo4MD for <notmuch@notmuchmail.org>;
\r
11 Tue, 17 Nov 2009 18:22:25 -0800 (PST)
\r
12 Received: from kaylee.flamingspork.com (kaylee.flamingspork.com
\r
14 by olra.theworths.org (Postfix) with ESMTP id 1AEA9431FAE
\r
15 for <notmuch@notmuchmail.org>; Tue, 17 Nov 2009 18:22:25 -0800 (PST)
\r
16 Received: from willster (localhost [127.0.0.1])
\r
17 by kaylee.flamingspork.com (Postfix) with ESMTPS id 9B6F46333;
\r
18 Wed, 18 Nov 2009 02:22:02 +0000 (UTC)
\r
19 Received: by willster (Postfix, from userid 1000)
\r
20 id 0029810F5D92; Wed, 18 Nov 2009 13:22:21 +1100 (EST)
\r
21 From: Stewart Smith <stewart@flamingspork.com>
\r
22 To: notmuch@notmuchmail.org
\r
23 Date: Wed, 18 Nov 2009 13:22:20 +1100
\r
24 Message-Id: <1258510940-7018-1-git-send-email-stewart@flamingspork.com>
\r
25 X-Mailer: git-send-email 1.6.3.3
\r
26 Subject: [notmuch] [PATCH] count_files: sort directory in inode order before
\r
28 X-BeenThere: notmuch@notmuchmail.org
\r
29 X-Mailman-Version: 2.1.12
\r
31 List-Id: "Use and development of the notmuch mail system."
\r
32 <notmuch.notmuchmail.org>
\r
33 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
34 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
35 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
36 List-Post: <mailto:notmuch@notmuchmail.org>
\r
37 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
38 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
39 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
40 X-List-Received-Date: Wed, 18 Nov 2009 02:22:25 -0000
\r
43 notmuch-new.c | 30 ++++++++++--------------------
\r
44 1 files changed, 10 insertions(+), 20 deletions(-)
\r
46 diff --git a/notmuch-new.c b/notmuch-new.c
\r
47 index 11fad8c..c5f841a 100644
\r
50 @@ -308,36 +308,26 @@ add_files (notmuch_database_t *notmuch,
\r
52 count_files (const char *path, int *count)
\r
55 - struct dirent *e, *entry = NULL;
\r
58 + struct dirent *entry = NULL;
\r
61 + struct dirent **namelist = NULL;
\r
63 - dir = opendir (path);
\r
64 + int n_entries= scandir(path, &namelist, 0, ino_cmp);
\r
66 - if (dir == NULL) {
\r
67 + if (n_entries == -1) {
\r
68 fprintf (stderr, "Warning: failed to open directory %s: %s\n",
\r
69 path, strerror (errno));
\r
73 - entry_length = offsetof (struct dirent, d_name) +
\r
74 - pathconf (path, _PC_NAME_MAX) + 1;
\r
75 - entry = malloc (entry_length);
\r
78 while (!interrupted) {
\r
79 - err = readdir_r (dir, entry, &e);
\r
81 - fprintf (stderr, "Error reading directory: %s\n",
\r
82 - strerror (errno));
\r
86 + if (i == n_entries)
\r
91 + entry= namelist[i++];
\r
93 /* Ignore special directories to avoid infinite recursion.
\r
94 * Also ignore the .notmuch directory.
\r
95 @@ -376,8 +366,8 @@ count_files (const char *path, int *count)
\r