forked from extern/nushell
nu-glob: add fs::symlink_metadata to detect broken symlinks (#5537)
* nu-glob: add fs::symlink_metadata to detect broken symlinks * fix join result
This commit is contained in:
parent
f818193b53
commit
3cef94ba39
@ -782,7 +782,11 @@ fn fill_todo(
|
|||||||
} else {
|
} else {
|
||||||
path.join(&s)
|
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);
|
add(todo, next_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -966,7 +970,7 @@ mod test {
|
|||||||
.and_then(|p| match p.components().next().unwrap() {
|
.and_then(|p| match p.components().next().unwrap() {
|
||||||
Component::Prefix(prefix_component) => {
|
Component::Prefix(prefix_component) => {
|
||||||
let path = Path::new(prefix_component.as_os_str()).join("*");
|
let path = Path::new(prefix_component.as_os_str()).join("*");
|
||||||
Some(path)
|
Some(path.to_path_buf())
|
||||||
}
|
}
|
||||||
_ => panic!("no prefix in this path"),
|
_ => panic!("no prefix in this path"),
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user