Closed TimNN closed 5 years ago
Thanks for the great bug report! This was a bit of a nasty one, I think it was introduced as a regression in https://github.com/BurntSushi/walkdir/commit/6f72fce4315cb13f2ceb6903910a52852a12ba0b. I've committed a fix to master. Once that passes CI, I'll put out a new release.
The fix is now on crates.io in walkdir 2.2.7
.
Thanks for the quick fix!
If the path passed to
WalkDir::new()
is a symlink to a file, calling.metadata()
on the producedDirEntry
returns the metadata of the symlink, rather than its target. This happens irrespective of whetherfollow_links
is set totrue
or not.The documentation of
WalkDir::new()
states thatGiven that documentation, I would have assumed that symlinks would always be followed for the metadata. But even if that documentation was not meant to be applied to root files, I would have still assumed that a root symlink would be followed if
follow_links
istrue
.To illustrate the problem use the following demo script:
If you pass a symlink to a file as an argument to the script, it will print
is_symlink: true
.If you pass a directory containing a symlink to a file as an argument, it will print
is_symlink: false
for the symlink.