kbknapp/cargo-count

cargo count dies if there are broken symlinks in tree

d3zd3z opened this issue · 2 comments

$ mkdir sample
$ cd sample
$ ln -s invalid foo
$ cargo count
Gathering information...
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }', src/libcore/result.rs:731

The culprit seems to be the calls to metadata in get_all_files, which will fail on a bogus symlink. Perhaps symlink_metadata would be better.

Thanks for taking the time to file this! This should be an easy fix.

This works now as cargo-count doesn't follow symlinks by default, but you can force it to by passing --follow-symlinks (or -S) and it shouldn't panic but instead function as expected.