X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-new.c;h=faeb8f0a5896a4e23b012c2ba6c0be986b5a01b4;hp=e011788da590a74433a526c5fe727e604be7db3e;hb=f2ed177e6260d835b8a13d2a53e1c8d5fa76edf2;hpb=43668950626f347f05aad7d49cd9ea4383030443 diff --git a/notmuch-new.c b/notmuch-new.c index e011788d..faeb8f0a 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -234,6 +234,12 @@ _entries_resemble_maildir (const char *path, struct dirent **entries, int count) return 0; } +static notmuch_bool_t +_special_directory (const char *entry) +{ + return strcmp (entry, ".") == 0 || strcmp (entry, "..") == 0; +} + /* Test if the file/directory is to be ignored. */ static notmuch_bool_t @@ -443,10 +449,7 @@ add_files (notmuch_database_t *notmuch, /* Pass 1: Recurse into all sub-directories. */ is_maildir = _entries_resemble_maildir (path, fs_entries, num_fs_entries); - for (i = 0; i < num_fs_entries; i++) { - if (interrupted) - break; - + for (i = 0; i < num_fs_entries && ! interrupted; i++) { entry = fs_entries[i]; /* Ignore any files/directories the user has configured to @@ -478,8 +481,7 @@ add_files (notmuch_database_t *notmuch, * Also ignore the .notmuch directory and any "tmp" directory * that appears within a maildir. */ - if (strcmp (entry->d_name, ".") == 0 || - strcmp (entry->d_name, "..") == 0 || + if (_special_directory (entry->d_name) || (is_maildir && strcmp (entry->d_name, "tmp") == 0) || strcmp (entry->d_name, ".notmuch") == 0) continue; @@ -514,11 +516,7 @@ add_files (notmuch_database_t *notmuch, } /* Pass 2: Scan for new files, removed files, and removed directories. */ - for (i = 0; i < num_fs_entries; i++) - { - if (interrupted) - break; - + for (i = 0; i < num_fs_entries && ! interrupted; i++) { entry = fs_entries[i]; /* Ignore files & directories user has configured to be ignored */ @@ -745,8 +743,7 @@ count_files (const char *path, int *count, add_files_state_t *state) /* Ignore special directories to avoid infinite recursion. * Also ignore the .notmuch directory. */ - if (strcmp (entry->d_name, ".") == 0 || - strcmp (entry->d_name, "..") == 0 || + if (_special_directory (entry->d_name) || strcmp (entry->d_name, ".notmuch") == 0) continue;