mirror of
https://github.com/nushell/nushell
synced 2025-01-26 03:45:19 +00:00
make du streaming
This commit is contained in:
parent
fff0c6e2cb
commit
65769d5033
1 changed files with 15 additions and 14 deletions
|
@ -170,6 +170,7 @@ fn du_for_one_pattern(
|
||||||
span: Span,
|
span: Span,
|
||||||
signals: &Signals,
|
signals: &Signals,
|
||||||
) -> Result<impl Iterator<Item = Value> + Send, ShellError> {
|
) -> Result<impl Iterator<Item = Value> + Send, ShellError> {
|
||||||
|
let signals_clone = signals.clone();
|
||||||
let exclude = args.exclude.map_or(Ok(None), move |x| {
|
let exclude = args.exclude.map_or(Ok(None), move |x| {
|
||||||
Pattern::new(x.item.as_ref())
|
Pattern::new(x.item.as_ref())
|
||||||
.map(Some)
|
.map(Some)
|
||||||
|
@ -179,7 +180,7 @@ fn du_for_one_pattern(
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let mut paths = match args.path {
|
let paths = match args.path {
|
||||||
Some(p) => nu_engine::glob_from(&p, current_dir, span, None),
|
Some(p) => nu_engine::glob_from(&p, current_dir, span, None),
|
||||||
// The * pattern should never fail.
|
// The * pattern should never fail.
|
||||||
None => nu_engine::glob_from(
|
None => nu_engine::glob_from(
|
||||||
|
@ -207,22 +208,22 @@ fn du_for_one_pattern(
|
||||||
long,
|
long,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut output: Vec<Value> = vec![];
|
Ok(paths.filter_map(move |p| match p {
|
||||||
for p in paths.by_ref() {
|
|
||||||
match p {
|
|
||||||
Ok(a) => {
|
Ok(a) => {
|
||||||
if a.is_dir() {
|
if a.is_dir() {
|
||||||
output.push(DirInfo::new(a, ¶ms, max_depth, span, signals)?.into());
|
match DirInfo::new(a, ¶ms, max_depth, span, &signals_clone) {
|
||||||
} else if let Ok(v) = FileInfo::new(a, deref, span, params.long) {
|
Ok(v) => Some(Value::from(v)),
|
||||||
output.push(v.into());
|
Err(_) => None,
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
Err(e) => {
|
match FileInfo::new(a, deref, span, params.long) {
|
||||||
output.push(Value::error(e, span));
|
Ok(v) => Some(Value::from(v)),
|
||||||
|
Err(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(output.into_iter())
|
Err(e) => Some(Value::error(e, span)),
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in a new issue