Skip to content

fs::metadata(entry_path).file_type().is_symlink() not work #39088

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

Closed
xiaozhuai opened this issue Jan 16, 2017 · 9 comments
Closed

fs::metadata(entry_path).file_type().is_symlink() not work #39088

xiaozhuai opened this issue Jan 16, 2017 · 9 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue.

Comments

@xiaozhuai
Copy link

let metadata = fs::metadata(file_path).try(stderr);
let filetype = metadata.file_type();
println!("{}", filetype.is_symlink());

It's always false.

@xiaozhuai
Copy link
Author

I'm on Linux Mint, the kernel version is 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016

@xiaozhuai
Copy link
Author

The file system is ext4

@nagisa
Copy link
Member

nagisa commented Jan 16, 2017

Duplicate of #29302; not a bug.

EDIT: Or rather, is a documentation bug.

@brson brson added the E-help-wanted Call for participation: Help is requested to fix this issue. label Jan 18, 2017
@brson
Copy link
Contributor

brson commented Jan 18, 2017

Update the docs for is_symlink to note that a common source of confusion is to call this on the result of fs::metadata not fs::symlink_metadata.

@brson brson added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Jan 18, 2017
@CartesianDaemon
Copy link
Contributor

Hi. I'm new to rust, and have been looking through the E-easy tagged bugs for one it would be easy to start with. (Thank you very much for making easy bugs available as on-ramps, it is very very much appreciated.)

I think the appropriate change is in src/libstd/fs.rs in the documentation for is_symlink(). Adding a second line to the description warning that you should use symlink_metadata by default, and changing the example to use fs::symlink_metadata() not fs::metadata().

I have made and tested that change locally. Does that sound right?

@nagisa
Copy link
Member

nagisa commented Jan 19, 2017

Does that sound right?

Yes.

I would suggest just submitting a PR. Reviewing (commenting on) code directly both spares you the effort describing the changes and us from parsing the description.

CartesianDaemon added a commit to CartesianDaemon/rust that referenced this issue Jan 19, 2017
fs::metadata() follows symlinks so is_symlink() will always return
false. Use symlink_metadata instead in the example in the
documentation.

See issue rust-lang#39088.
bors added a commit that referenced this issue Jan 22, 2017
Use fs::symlink_metadata in doc for is_symlink

fs::metadata() follows symlinks so is_symlink() will always return
false. Use symlink_metadata instead in the example in the
documentation.

See issue #39088.
@phungleson
Copy link
Contributor

I believe this one is done?

@CartesianDaemon
Copy link
Contributor

Assuming I'm right, yes, I think my commit fixed this particular issue, did everything suggested, and is now merged safely to master.

@frewsxcv
Copy link
Member

frewsxcv commented Feb 8, 2017

Addressed by @CartesianDaemon in #39176. Thanks again!

@frewsxcv frewsxcv closed this as completed Feb 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue.
Projects
None yet
Development

No branches or pull requests

7 participants