]> git.notmuchmail.org Git - notmuch/commitdiff
new: Skip ignored broken symlinks
authorAustin Clements <amdragon@MIT.EDU>
Sun, 25 Nov 2012 05:25:45 +0000 (00:25 -0500)
committerDavid Bremner <bremner@debian.org>
Tue, 27 Nov 2012 02:17:20 +0000 (22:17 -0400)
We now test for user ignore patterns before attempting to determine if
a directory entry is itself a directory.  As a result, we no longer
abort for broken symlinks if the user has explicitly ignored them.

This fixes the test added in the previous patch.  It also slightly
changes the debug output checked by another test of ignores.

notmuch-new.c
test/new

index 56c4a6fdd62a3f25709de37730bd0864532bf5bb..718a5387c81c235e7f70c14c5a5fa3b01963e17e 100644 (file)
@@ -350,6 +350,18 @@ add_files (notmuch_database_t *notmuch,
 
        entry = fs_entries[i];
 
+       /* Ignore any files/directories the user has configured to
+        * ignore.  We do this before dirent_type both for performance
+        * and because we don't care if dirent_type fails on entries
+        * that are explicitly ignored.
+        */
+       if (_entry_in_ignore_list (entry->d_name, state)) {
+           if (state->debug)
+               printf ("(D) add_files_recursive, pass 1: explicitly ignoring %s/%s\n",
+                       path, entry->d_name);
+           continue;
+       }
+
        /* We only want to descend into directories (and symlinks to
         * directories). */
        entry_type = dirent_type (path, entry);
@@ -364,22 +376,14 @@ add_files (notmuch_database_t *notmuch,
        }
 
        /* Ignore special directories to avoid infinite recursion.
-        * Also ignore the .notmuch directory, any "tmp" directory
-        * that appears within a maildir and files/directories
-        * the user has configured to be ignored.
+        * 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 ||
            (is_maildir && strcmp (entry->d_name, "tmp") == 0) ||
-           strcmp (entry->d_name, ".notmuch") == 0 ||
-           _entry_in_ignore_list (entry->d_name, state))
-       {
-           if (_entry_in_ignore_list (entry->d_name, state) && state->debug)
-               printf ("(D) add_files_recursive, pass 1: explicitly ignoring %s/%s\n",
-                       path,
-                       entry->d_name);
+           strcmp (entry->d_name, ".notmuch") == 0)
            continue;
-       }
 
        next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
        status = add_files (notmuch, next, state);
index ea678d7c0f425ec7c564de872741142a67e6b2c2..3eff2fe9e22ec8d25f0e85c523bcb914a519bdb9 100755 (executable)
--- a/test/new
+++ b/test/new
@@ -225,7 +225,12 @@ touch "${MAIL_DIR}"/{one,one/two,one/two/three}/ignored_file
 output=$(NOTMUCH_NEW --debug 2>&1 | sort)
 test_expect_equal "$output" \
 "(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/.git
+(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/.ignored_hidden_file
+(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/ignored_file
+(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/ignored_file
+(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/two/ignored_file
 (D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/two/three/.git
+(D) add_files_recursive, pass 1: explicitly ignoring ${MAIL_DIR}/one/two/three/ignored_file
 (D) add_files_recursive, pass 2: explicitly ignoring ${MAIL_DIR}/.git
 (D) add_files_recursive, pass 2: explicitly ignoring ${MAIL_DIR}/.ignored_hidden_file
 (D) add_files_recursive, pass 2: explicitly ignoring ${MAIL_DIR}/ignored_file
@@ -237,7 +242,6 @@ No new mail."
 
 
 test_begin_subtest "Don't stop for ignored broken symlinks"
-test_subtest_known_broken
 notmuch config set new.ignore .git ignored_file .ignored_hidden_file broken_link
 ln -s i_do_not_exist "${MAIL_DIR}"/broken_link
 output=$(NOTMUCH_NEW 2>&1)