mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 19:08:09 +01:00
971cdc72cd
We largely use the corpus under test/corpus for testing. Unfortunately, many of our tests have grown to depend on having exactly this set of messages, making it hard to add new message files for testing specific cases. We do use a lot of add_message from within the tests, but it's not possible to use that for adding broken messages, and adding several messages at once can get unwieldy. Move the basic corpus under tests/corpora/default, and make it possible to add new, independent corpora along its side. This means tons of renames with a few tweaks to add_email_corpus function in test-lib.sh to let tests specify which corpus to use.
75 lines
1.8 KiB
Text
75 lines
1.8 KiB
Text
From: "Stewart Smith" <stewart@flamingspork.com>
|
|
To: notmuch@notmuchmail.org
|
|
Date: Wed, 18 Nov 2009 13:22:20 +1100
|
|
Subject: [notmuch] [PATCH] count_files: sort directory in inode order before
|
|
statting
|
|
Message-ID: <1258510940-7018-1-git-send-email-stewart@flamingspork.com>
|
|
|
|
---
|
|
notmuch-new.c | 30 ++++++++++--------------------
|
|
1 files changed, 10 insertions(+), 20 deletions(-)
|
|
|
|
diff --git a/notmuch-new.c b/notmuch-new.c
|
|
index 11fad8c..c5f841a 100644
|
|
--- a/notmuch-new.c
|
|
+++ b/notmuch-new.c
|
|
@@ -308,36 +308,26 @@ add_files (notmuch_database_t *notmuch,
|
|
static void
|
|
count_files (const char *path, int *count)
|
|
{
|
|
- DIR *dir;
|
|
- struct dirent *e, *entry = NULL;
|
|
- int entry_length;
|
|
- int err;
|
|
+ struct dirent *entry = NULL;
|
|
char *next;
|
|
struct stat st;
|
|
+ struct dirent **namelist = NULL;
|
|
|
|
- dir = opendir (path);
|
|
+ int n_entries= scandir(path, &namelist, 0, ino_cmp);
|
|
|
|
- if (dir == NULL) {
|
|
+ if (n_entries == -1) {
|
|
fprintf (stderr, "Warning: failed to open directory %s: %s\n",
|
|
path, strerror (errno));
|
|
goto DONE;
|
|
}
|
|
|
|
- entry_length = offsetof (struct dirent, d_name) +
|
|
- pathconf (path, _PC_NAME_MAX) + 1;
|
|
- entry = malloc (entry_length);
|
|
+ int i=0;
|
|
|
|
while (!interrupted) {
|
|
- err = readdir_r (dir, entry, &e);
|
|
- if (err) {
|
|
- fprintf (stderr, "Error reading directory: %s\n",
|
|
- strerror (errno));
|
|
- free (entry);
|
|
- goto DONE;
|
|
- }
|
|
+ if (i == n_entries)
|
|
+ break;
|
|
|
|
- if (e == NULL)
|
|
- break;
|
|
+ entry= namelist[i++];
|
|
|
|
/* Ignore special directories to avoid infinite recursion.
|
|
* Also ignore the .notmuch directory.
|
|
@@ -376,8 +366,8 @@ count_files (const char *path, int *count)
|
|
DONE:
|
|
if (entry)
|
|
free (entry);
|
|
-
|
|
- closedir (dir);
|
|
+ if (namelist)
|
|
+ free (namelist);
|
|
}
|
|
|
|
int
|
|
--
|
|
1.6.3.3
|
|
|
|
|