From 3cef94ba394325938a1c06c274d44283e7060239 Mon Sep 17 00:00:00 2001 From: Herlon Aguiar Date: Sat, 14 May 2022 02:56:26 +0200 Subject: [PATCH] nu-glob: add fs::symlink_metadata to detect broken symlinks (#5537) * nu-glob: add fs::symlink_metadata to detect broken symlinks * fix join result --- crates/nu-glob/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/nu-glob/src/lib.rs b/crates/nu-glob/src/lib.rs index ddaefc458d..a312f29217 100644 --- a/crates/nu-glob/src/lib.rs +++ b/crates/nu-glob/src/lib.rs @@ -782,7 +782,11 @@ fn fill_todo( } else { path.join(&s) }; - if (special && is_dir) || (!special && fs::metadata(&next_path).is_ok()) { + if (special && is_dir) + || (!special + && (fs::metadata(&next_path).is_ok() + || fs::symlink_metadata(&next_path).is_ok())) + { add(todo, next_path); } } @@ -966,7 +970,7 @@ mod test { .and_then(|p| match p.components().next().unwrap() { Component::Prefix(prefix_component) => { let path = Path::new(prefix_component.as_os_str()).join("*"); - Some(path) + Some(path.to_path_buf()) } _ => panic!("no prefix in this path"), })