style: cargo fmt

This commit is contained in:
Mathias Zhang 2025-07-03 20:35:32 +08:00
parent cd104a2377
commit 7e63526abc
No known key found for this signature in database
5 changed files with 16 additions and 15 deletions

View File

@ -68,16 +68,20 @@ pub fn compress_files(
)
}
Lz4 => Box::new(lz4_flex::frame::FrameEncoder::new(encoder).auto_finish()),
Lzma => return Err(crate::Error::UnsupportedFormat {
Lzma => {
return Err(crate::Error::UnsupportedFormat {
reason: "LZMA1 compression is not supported in ouch, use .xz instead.".to_string(),
}),
})
}
Xz => Box::new(liblzma::write::XzEncoder::new(
encoder,
level.map_or(6, |l| (l as u32).clamp(0, 9)),
)),
Lzip => return Err(crate::Error::UnsupportedFormat {
Lzip => {
return Err(crate::Error::UnsupportedFormat {
reason: "Lzip compression is not supported in ouch.".to_string(),
}),
})
}
Snappy => Box::new(
gzp::par::compress::ParCompress::<gzp::snap::Snap>::builder()
.compression_level(gzp::par::compress::Compression::new(

View File

@ -128,8 +128,9 @@ pub fn decompress_file(options: DecompressOptions) -> crate::Result<()> {
Box::new(bzip3::read::Bz3Decoder::new(decoder)?)
}
Lz4 => Box::new(lz4_flex::frame::FrameDecoder::new(decoder)),
Lzma => Box::new(liblzma::read::XzDecoder::new_stream(decoder,
liblzma::stream::Stream::new_lzma_decoder(u64::MAX).unwrap()
Lzma => Box::new(liblzma::read::XzDecoder::new_stream(
decoder,
liblzma::stream::Stream::new_lzma_decoder(u64::MAX).unwrap(),
)),
Xz => Box::new(liblzma::read::XzDecoder::new(decoder)),
Lzip => Box::new(liblzma::read::XzDecoder::new_stream(

View File

@ -136,10 +136,7 @@ pub fn try_infer_extension(path: &Path) -> Option<Extension> {
buf.starts_with(b"BZ3v1")
}
fn is_lzma(buf: &[u8]) -> bool {
buf.len() >= 14
&& buf[0] == 0x5d
&& (buf[12] == 0x00 || buf[12] == 0xff)
&& buf[13] == 0x00
buf.len() >= 14 && buf[0] == 0x5d && (buf[12] == 0x00 || buf[12] == 0xff) && buf[13] == 0x00
}
fn is_xz(buf: &[u8]) -> bool {
buf.starts_with(&[0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])

View File

@ -17,8 +17,7 @@ fn sanity_check_through_mime() {
write_random_content(test_file, &mut SmallRng::from_entropy());
let formats = [
"7z", "tar", "zip", "tar.gz", "tgz", "tbz", "tbz2", "txz", "tzst", "tar.bz", "tar.bz2",
"tar.xz", "tar.zst",
"7z", "tar", "zip", "tar.gz", "tgz", "tbz", "tbz2", "txz", "tzst", "tar.bz", "tar.bz2", "tar.xz", "tar.zst",
];
let expected_mimes = [