report and skip broken symlinks#136
Conversation
| if is_broken_symlink(&entry_path_buf) { | ||
| println!("Warning: '{}' is a broken symlink", entry_path_buf.display()); | ||
| continue; | ||
| } |
There was a problem hiding this comment.
Just an idea, but could this check be moved to if an actual error is produced? I assume it'd be in the line below, let metadata = fs::metadata(&entry_path_buf)?;.
Maybe it doesn't matter in practice, but sometimes these FS APIs incur latency, so it'd be nice to avoid using it unless actually needed, which I guess is only if it actually errors.
There was a problem hiding this comment.
Yeah - +1 @adnelson -- I think push these to both 169, as well as 471. I think both those could potentially be symlinked folders. Other than that, great stuff.
It reminds me that I should probably pick up the PR to add proper log levels again at some point.
There was a problem hiding this comment.
@adnelson -- We've added some better loggin structure, feel free to rebase and update the PR.
If you don't feel like it - I'd be happy to take this over and finish it, I think this could be nice to have :)
I was running
rewatch buildon my project for the first time and it failed, confusingly claimingCould not read folder: src..., despitesrcclearly existing.Upon some investigation the error was actually that I had a broken symlink (pointing to a non-existent file) in my project directory tree, which caused the like
let metadata = fs::metadata(&entry_path_buf)?;to return an error, tanking the whole process.The fix I have here checks specifically for a broken symlink, and if found, reports it and skips (
continues) the loop. With this change, my project compiled without errors.I also added the text of the error to the
println!s reporting errors in a few places, with the idea that that might help make things clearer to a user. It's not part of the core fix here, so feel free to remove if undesirable.