Skip to content

Commit 3b387dd

Browse files
authored
unify log messages between formats when decompressing (#937)
1 parent 0a92b86 commit 3b387dd

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Categories Used:
3333

3434
### Tweaks
3535

36+
- Unify directory extraction message for zip and tar archives (https://github.com/ouch-org/ouch/pull/937)
37+
3638
## [0.7.0](https://github.com/ouch-org/ouch/releases/tag/0.7.0)
3739

3840
### Removals

src/archive/tar.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,15 @@ pub fn unpack_archive(reader: impl Read, output_folder: &Path) -> Result<u64> {
8080
_ => continue,
8181
}
8282

83-
info!(
84-
"extracted ({}) {}",
85-
BytesFmt(entry.size()),
86-
PathFmt(&output_folder.join(entry.path()?)),
87-
);
83+
if entry.header().entry_type().is_dir() {
84+
info!("Directory {} created", PathFmt(&output_folder.join(entry.path()?)));
85+
} else {
86+
info!(
87+
"extracted ({}) {}",
88+
BytesFmt(entry.size()),
89+
PathFmt(&output_folder.join(entry.path()?)),
90+
);
91+
}
8892
files_unpacked += 1;
8993
}
9094

src/archive/zip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ where
5353

5454
match file.name().ends_with('/') {
5555
_is_dir @ true => {
56-
info!("File {} extracted to {}", idx, PathFmt(&file_path));
56+
info!("Directory {} created", PathFmt(&file_path));
5757

5858
let mode = file.unix_mode();
5959
let is_symlink = mode.is_some_and(|mode| mode & 0o170000 == 0o120000);

tests/snapshots/ui__ui_test_ok_decompress_multiple_files.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
source: tests/ui.rs
33
expression: "lines.join(\"\\n\")"
44
---
5+
[INFO] Directory "output/input" created
56
[INFO] Files unpacked: 4
67
[INFO] Successfully decompressed archive to "output"
7-
[INFO] extracted ( [SIZE]) "output/input"
88
[INFO] extracted ( [SIZE]) "output/input/input"
99
[INFO] extracted ( [SIZE]) "output/input/input2"
1010
[INFO] extracted ( [SIZE]) "output/input/input3"

0 commit comments

Comments
 (0)