]> git.notmuchmail.org Git - notmuch/commitdiff
Add some comments to document the recently-fixed handling of d_type.
authorCarl Worth <cworth@cworth.org>
Sat, 23 Jan 2010 05:58:30 +0000 (18:58 +1300)
committerCarl Worth <cworth@cworth.org>
Sat, 23 Jan 2010 05:58:30 +0000 (18:58 +1300)
The fix was subtle, (requiring less code than originally expected), so
it behooves us to document it well.

notmuch-new.c

index 3e6b96a7c45688501b512650d9332ac1c02032b2..124d38dc96395613a2316a2e12cbf048a8bd78ff 100644 (file)
@@ -273,9 +273,19 @@ add_files_recursive (notmuch_database_t *notmuch,
 
        entry = fs_entries[i];
 
 
        entry = fs_entries[i];
 
-       if (entry->d_type != DT_DIR && entry->d_type != DT_LNK
-                       && entry->d_type != DT_UNKNOWN)
+       /* We only want to descend into directories.
+        * But symlinks can be to directories too, of course.
+        *
+        * And if the filesystem doesn't tell us the file type in the
+        * scandir results, then it might be a directory (and if not,
+        * then we'll stat and return immediately in the next level of
+        * recursion). */
+       if (entry->d_type != DT_DIR &&
+           entry->d_type != DT_LNK &&
+           entry->d_type != DT_UKNOWN)
+       {
            continue;
            continue;
+       }
 
        /* Ignore special directories to avoid infinite recursion.
         * Also ignore the .notmuch directory and any "tmp" directory
 
        /* Ignore special directories to avoid infinite recursion.
         * Also ignore the .notmuch directory and any "tmp" directory
@@ -343,7 +353,13 @@ add_files_recursive (notmuch_database_t *notmuch,
        }
 
        /* If we're looking at a symlink, we only want to add it if it
        }
 
        /* If we're looking at a symlink, we only want to add it if it
-        * links to a regular file, (and not to a directory, say). */
+        * links to a regular file, (and not to a directory, say).
+        *
+        * Similarly, if the file is of unknown type (due to filesytem
+        * limitations), then we also need to look closer.
+        *
+        * In either case, a stat does the trick.
+        */
        if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {
            int err;
 
        if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {
            int err;