diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-12-30 10:56:09 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-12-30 10:56:09 +0200 |
commit | 6ee33dbcec61ae7980ba9ece6b75bc9cfa9655c2 (patch) | |
tree | dda1c143170be20907f1acd1ca8f78c30ea40ee1 | |
parent | bf77eb2d929a8536cd6e095da473eab5144c6695 (diff) | |
download | summain-rs-6ee33dbcec61ae7980ba9ece6b75bc9cfa9655c2.tar.gz |
fix: handle dangling symlinks on command line
Sponsored-by: author
-rw-r--r-- | src/bin/summain.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bin/summain.rs b/src/bin/summain.rs index 9365243..dbf8452 100644 --- a/src/bin/summain.rs +++ b/src/bin/summain.rs @@ -55,6 +55,13 @@ async fn main() -> anyhow::Result<()> { } fn find(root: &Path, files: &mut Vec<PathBuf>) -> anyhow::Result<()> { + let meta = std::fs::symlink_metadata(root)?; + if meta.file_type().is_symlink() { + // Walkdir doesn't handle dangling symlinks so we handle all + // symlinks here. + files.push(root.to_path_buf()); + return Ok(()); + } for e in WalkDir::new(root) { files.push(e?.path().to_path_buf()); } |