Skip to content

Commit

Permalink
Add some comments to document the recently-fixed handling of d_type.
Browse files Browse the repository at this point in the history
The fix was subtle, (requiring less code than originally expected), so
it behooves us to document it well.
  • Loading branch information
cworth-gh committed Jan 23, 2010
1 parent c5416b6 commit 344c48a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions notmuch-new.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,19 @@ add_files_recursive (notmuch_database_t *notmuch,

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;
}

/* Ignore special directories to avoid infinite recursion.
* Also ignore the .notmuch directory and any "tmp" directory
Expand Down Expand Up @@ -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
* 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;

Expand Down

0 comments on commit 344c48a

Please sign in to comment.