fix: update tests, comments and docs

This commit is contained in:
oxalica 2025-07-02 01:54:09 -04:00
parent 0121a0c0df
commit bef287039a
10 changed files with 24 additions and 22 deletions

View File

@ -111,9 +111,9 @@ Output:
# Supported formats # Supported formats
| Format | `.tar` | `.zip` | `7z` | `.gz` | `.xz`, `.lzma` | `.bz`, `.bz2` | `.bz3` | `.lz4` | `.sz` (Snappy) | `.zst` | `.rar` | `.br` | | Format | `.tar` | `.zip` | `7z` | `.gz` | `.xz`, `.lzma` | `.bz`, `.bz2` | `.bz3` | `.lz4` | `.sz` (Snappy) | `.zst` | `.rar` | `.br` | `.sqfs`, `.squashfs` |
|:---------:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| |:---------:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| Supported | ✓ | ✓¹ | ✓¹ | ✓² | ✓ | ✓ | ✓ | ✓ | ✓² | ✓² | ✓³ | ✓ | | Supported | ✓ | ✓¹ | ✓¹ | ✓² | ✓ | ✓ | ✓ | ✓ | ✓² | ✓² | ✓³ | ✓ | ✓¹ |
✓: Supports compression and decompression. ✓: Supports compression and decompression.

View File

@ -49,13 +49,13 @@ pub fn decompress_file(options: DecompressOptions) -> crate::Result<()> {
assert!(options.output_dir.exists()); assert!(options.output_dir.exists());
let input_is_stdin = is_path_stdin(options.input_file_path); let input_is_stdin = is_path_stdin(options.input_file_path);
// Zip archives are special, because they require io::Seek, so it requires it's logic separated // Zip and squashfs archives are special, because they require io::Seek, so it requires it's logic separated
// from decoder chaining. // from decoder chaining.
// //
// This is the only case where we can read and unpack it directly, without having to do // This is the only case where we can read and unpack it directly, without having to do
// in-memory decompression/copying first. // in-memory decompression/copying first.
// //
// Any other Zip decompression done can take up the whole RAM and freeze ouch. // Any other decompression done can take up the whole RAM and freeze ouch.
if let [Extension { if let [Extension {
compression_formats: [archive_format @ (Zip | Squashfs)], compression_formats: [archive_format @ (Zip | Squashfs)],
.. ..

View File

@ -25,7 +25,7 @@ pub fn list_archive_contents(
) -> crate::Result<()> { ) -> crate::Result<()> {
let reader = fs::File::open(archive_path)?; let reader = fs::File::open(archive_path)?;
// Zip archives are special, because they require io::Seek, so it requires it's logic separated // Zip and squashfs archives are special, because they require io::Seek, so it requires it's logic separated
// from decoder chaining. // from decoder chaining.
// //
// This is the only case where we can read and unpack it directly, without having to do // This is the only case where we can read and unpack it directly, without having to do

View File

@ -25,16 +25,18 @@ pub const SUPPORTED_EXTENSIONS: &[&str] = &[
"rar", "rar",
"7z", "7z",
"br", "br",
// TODO(review): Which to use as "official" extension? squashfs or sqfs?
"sqfs",
]; ];
pub const SUPPORTED_ALIASES: &[&str] = &["tgz", "tbz", "tlz4", "txz", "tzlma", "tsz", "tzst"]; pub const SUPPORTED_ALIASES: &[&str] = &["tgz", "tbz", "tlz4", "txz", "tzlma", "tsz", "tzst", "squashfs"];
#[cfg(not(feature = "unrar"))] #[cfg(not(feature = "unrar"))]
pub const PRETTY_SUPPORTED_EXTENSIONS: &str = "tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, 7z"; pub const PRETTY_SUPPORTED_EXTENSIONS: &str = "tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, 7z, sqfs";
#[cfg(feature = "unrar")] #[cfg(feature = "unrar")]
pub const PRETTY_SUPPORTED_EXTENSIONS: &str = "tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z"; pub const PRETTY_SUPPORTED_EXTENSIONS: &str = "tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z, sqfs";
pub const PRETTY_SUPPORTED_ALIASES: &str = "tgz, tbz, tlz4, txz, tzlma, tsz, tzst"; pub const PRETTY_SUPPORTED_ALIASES: &str = "tgz, tbz, tlz4, txz, tzlma, tsz, tzst, squashfs";
/// A wrapper around `CompressionFormat` that allows combinations like `tgz` /// A wrapper around `CompressionFormat` that allows combinations like `tgz`
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View File

@ -6,8 +6,8 @@ expression: "run_ouch(\"ouch decompress a\", dir)"
- Files with missing extensions: <TMP_DIR>/a - Files with missing extensions: <TMP_DIR>/a
- Decompression formats are detected automatically from file extension - Decompression formats are detected automatically from file extension
hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z, sqfs
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, squashfs
hint: hint:
hint: Alternatively, you can pass an extension to the '--format' flag: hint: Alternatively, you can pass an extension to the '--format' flag:
hint: ouch decompress <TMP_DIR>/a --format tar.gz hint: ouch decompress <TMP_DIR>/a --format tar.gz

View File

@ -7,5 +7,5 @@ expression: "run_ouch(\"ouch decompress a b.unknown\", dir)"
- Files with missing extensions: <TMP_DIR>/a - Files with missing extensions: <TMP_DIR>/a
- Decompression formats are detected automatically from file extension - Decompression formats are detected automatically from file extension
hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z, sqfs
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, squashfs

View File

@ -6,8 +6,8 @@ expression: "run_ouch(\"ouch decompress b.unknown\", dir)"
- Files with unsupported extensions: <TMP_DIR>/b.unknown - Files with unsupported extensions: <TMP_DIR>/b.unknown
- Decompression formats are detected automatically from file extension - Decompression formats are detected automatically from file extension
hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z, sqfs
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, squashfs
hint: hint:
hint: Alternatively, you can pass an extension to the '--format' flag: hint: Alternatively, you can pass an extension to the '--format' flag:
hint: ouch decompress <TMP_DIR>/b.unknown --format tar.gz hint: ouch decompress <TMP_DIR>/b.unknown --format tar.gz

View File

@ -5,8 +5,8 @@ expression: "run_ouch(\"ouch compress input output --format tar.gz.unknown\", di
[ERROR] Failed to parse `--format tar.gz.unknown` [ERROR] Failed to parse `--format tar.gz.unknown`
- Unsupported extension 'unknown' - Unsupported extension 'unknown'
hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z, sqfs
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, squashfs
hint: hint:
hint: Examples: hint: Examples:
hint: --format tar hint: --format tar

View File

@ -5,8 +5,8 @@ expression: "run_ouch(\"ouch compress input output --format targz\", dir)"
[ERROR] Failed to parse `--format targz` [ERROR] Failed to parse `--format targz`
- Unsupported extension 'targz' - Unsupported extension 'targz'
hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z, sqfs
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, squashfs
hint: hint:
hint: Examples: hint: Examples:
hint: --format tar hint: --format tar

View File

@ -5,8 +5,8 @@ expression: "run_ouch(\"ouch compress input output --format .tar.$#!@.rest\", di
[ERROR] Failed to parse `--format .tar.$#!@.rest` [ERROR] Failed to parse `--format .tar.$#!@.rest`
- Unsupported extension '$#!@' - Unsupported extension '$#!@'
hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z hint: Supported extensions are: tar, zip, bz, bz2, bz3, gz, lz4, xz, lzma, sz, zst, rar, 7z, sqfs
hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst, squashfs
hint: hint:
hint: Examples: hint: Examples:
hint: --format tar hint: --format tar