mirror of
https://github.com/nushell/nushell.git
synced 2024-12-22 15:13:01 +01:00
ls
now collects metadata in a separate thread.
This commit is contained in:
parent
e26364f885
commit
c79ff99e0d
@ -317,6 +317,7 @@ fn ls_for_one_pattern(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let hidden_dir_specified = is_hidden_dir(pattern_arg.as_ref());
|
let hidden_dir_specified = is_hidden_dir(pattern_arg.as_ref());
|
||||||
|
|
||||||
let path = pattern_arg.into_spanned(p_tag);
|
let path = pattern_arg.into_spanned(p_tag);
|
||||||
let (prefix, paths) = if just_read_dir {
|
let (prefix, paths) = if just_read_dir {
|
||||||
let expanded = nu_path::expand_path_with(path.item.as_ref(), &cwd, path.item.is_expand());
|
let expanded = nu_path::expand_path_with(path.item.as_ref(), &cwd, path.item.is_expand());
|
||||||
@ -359,7 +360,8 @@ fn ls_for_one_pattern(
|
|||||||
};
|
};
|
||||||
|
|
||||||
pool.install(|| {
|
pool.install(|| {
|
||||||
paths_peek
|
rayon::spawn(move || {
|
||||||
|
let result = paths_peek
|
||||||
.par_bridge()
|
.par_bridge()
|
||||||
.filter_map(move |x| match x {
|
.filter_map(move |x| match x {
|
||||||
Ok(path) => {
|
Ok(path) => {
|
||||||
@ -391,8 +393,9 @@ fn ls_for_one_pattern(
|
|||||||
if let Ok(remainder) = path.strip_prefix(prefix) {
|
if let Ok(remainder) = path.strip_prefix(prefix) {
|
||||||
if directory {
|
if directory {
|
||||||
// When the path is the same as the cwd, path_diff should be "."
|
// When the path is the same as the cwd, path_diff should be "."
|
||||||
let path_diff =
|
let path_diff = if let Some(path_diff_not_dot) =
|
||||||
if let Some(path_diff_not_dot) = diff_paths(&path, &cwd) {
|
diff_paths(&path, &cwd)
|
||||||
|
{
|
||||||
let path_diff_not_dot = path_diff_not_dot.to_string_lossy();
|
let path_diff_not_dot = path_diff_not_dot.to_string_lossy();
|
||||||
if path_diff_not_dot.is_empty() {
|
if path_diff_not_dot.is_empty() {
|
||||||
".".to_string()
|
".".to_string()
|
||||||
@ -459,14 +462,19 @@ fn ls_for_one_pattern(
|
|||||||
inner: vec![],
|
inner: vec![],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
.map_err(|err| ShellError::GenericError {
|
.map_err(|err| ShellError::GenericError {
|
||||||
error: "Unable to create a rayon pool".into(),
|
error: "Unable to create a rayon pool".into(),
|
||||||
msg: err.to_string(),
|
msg: err.to_string(),
|
||||||
span: Some(call_span),
|
span: Some(call_span),
|
||||||
help: None,
|
help: None,
|
||||||
inner: vec![],
|
inner: vec![],
|
||||||
})?;
|
});
|
||||||
|
|
||||||
|
if let Err(error) = result {
|
||||||
|
let _ = tx.send(Value::error(error, call_span));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Ok(rx
|
Ok(rx
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
Loading…
Reference in New Issue
Block a user