mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-03 10:00:19 +00:00
fix: Use BufWriter for list output
Also replaces one `print` call with `write`. Fixes #702
This commit is contained in:
parent
28d0933d6c
commit
aeefa694bf
@ -41,6 +41,7 @@ Categories Used:
|
||||
- Fix logging IO bottleneck [\#642](https://github.com/ouch-org/ouch/pull/642) ([AntoniosBarotsis](https://github.com/AntoniosBarotsis))
|
||||
- Support decompression over stdin [\#692](https://github.com/ouch-org/ouch/pull/692) ([rcorre](https://github.com/rcorre))
|
||||
- Make `--format` more forgiving with the formatting of the provided format [\#519](https://github.com/ouch-org/ouch/pull/519) ([marcospb19](https://github.com/marcospb19))
|
||||
- Use buffered writer for list output [\#764](https://github.com/ouch-org/ouch/pull/764) ([killercup](https://github.com/killercup))
|
||||
|
||||
## [0.5.1](https://github.com/ouch-org/ouch/compare/0.5.0...0.5.1)
|
||||
|
||||
|
10
src/list.rs
10
src/list.rs
@ -1,7 +1,7 @@
|
||||
//! Some implementation helpers related to the 'list' command.
|
||||
|
||||
use std::{
|
||||
io::{stdout, Write},
|
||||
io::{stdout, BufWriter, Write},
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
@ -32,16 +32,16 @@ pub fn list_files(
|
||||
files: impl IntoIterator<Item = crate::Result<FileInArchive>>,
|
||||
list_options: ListOptions,
|
||||
) -> crate::Result<()> {
|
||||
let out = &mut stdout().lock();
|
||||
let mut out = BufWriter::new(stdout().lock());
|
||||
let _ = writeln!(out, "Archive: {}", EscapedPathDisplay::new(archive));
|
||||
|
||||
if list_options.tree {
|
||||
let tree = files.into_iter().collect::<crate::Result<Tree>>()?;
|
||||
tree.print(out);
|
||||
tree.print(&mut out);
|
||||
} else {
|
||||
for file in files {
|
||||
let FileInArchive { path, is_dir } = file?;
|
||||
print_entry(out, EscapedPathDisplay::new(&path), is_dir);
|
||||
print_entry(&mut out, EscapedPathDisplay::new(&path), is_dir);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@ -143,7 +143,7 @@ mod tree {
|
||||
false => draw::FINAL_BRANCH,
|
||||
};
|
||||
|
||||
print!("{prefix}{final_part}");
|
||||
let _ = write!(out, "{prefix}{final_part}");
|
||||
let is_dir = match self.file {
|
||||
Some(FileInArchive { is_dir, .. }) => is_dir,
|
||||
None => true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user