Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symlinks pointing to regular files are detected as regular files #139

Closed
SoresViktor opened this issue Mar 24, 2023 · 2 comments · Fixed by #140
Closed

Symlinks pointing to regular files are detected as regular files #139

SoresViktor opened this issue Mar 24, 2023 · 2 comments · Fixed by #140

Comments

@SoresViktor
Copy link

Here, on line 35, I think it should be file_type, not path:

fn from_path(path: &path::Path, follow: bool) -> io::Result<FileType> {
let file_type = if follow {
path.metadata()
} else {
path.symlink_metadata()
}?
.file_type();
if file_type.is_dir() {
return Ok(FileType::Dir);
}
if path.is_file() {
return Ok(FileType::File);
}
Ok(FileType::Symlink)
}

Path::is_file always follows symlinks and will return true if the symlink points to a regular file.

This is probably the root cause of assert-rs/assert_fs#70.

epage added a commit to epage/predicates-rs that referenced this issue Mar 24, 2023
@epage
Copy link
Contributor

epage commented Mar 24, 2023

Thanks for catching that!

@SoresViktor
Copy link
Author

Wow, fastest fix ever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants