mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-05 02:55:31 +00:00
Added test code, handled BlockSize error, block size = 16MiB
Signed-off-by: Jonas Frei <freijon@pm.me>
This commit is contained in:
parent
ba9f9c00f3
commit
32b50e9c7a
@ -178,7 +178,6 @@ Otherwise, you'll need these libraries installed on your system:
|
||||
* [libbz2](https://www.sourceware.org/bzip2)
|
||||
* [libbz3](https://github.com/kspalaiologos/bzip3)
|
||||
* [libz](https://www.zlib.net)
|
||||
>>>>>>> 066184e (Add support for bzip3)
|
||||
|
||||
These should be available in your system's package manager.
|
||||
|
||||
|
@ -57,8 +57,8 @@ pub fn compress_files(
|
||||
level.map_or_else(Default::default, |l| bzip2::Compression::new((l as u32).clamp(1, 9))),
|
||||
)),
|
||||
Bzip3 => Box::new(
|
||||
// Unwrap is safe when using a valid block size
|
||||
bzip3::write::Bz3Encoder::new(encoder, bytesize::ByteSize::mib(5).0 as usize).unwrap(),
|
||||
// Use block size of 16 MiB
|
||||
bzip3::write::Bz3Encoder::new(encoder, 16 * 2_usize.pow(20))?,
|
||||
),
|
||||
Lz4 => Box::new(lz4_flex::frame::FrameEncoder::new(encoder).auto_finish()),
|
||||
Lzma => Box::new(xz2::write::XzEncoder::new(
|
||||
|
12
src/error.rs
12
src/error.rs
@ -200,6 +200,18 @@ impl From<std::io::Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bzip3::Error> for Error {
|
||||
fn from(err: bzip3::Error) -> Self {
|
||||
use bzip3::Error as Bz3Error;
|
||||
match err {
|
||||
Bz3Error::Io(inner) => inner.into(),
|
||||
Bz3Error::BlockSize | Bz3Error::ProcessBlock(_) | Bz3Error::InvalidSignature => {
|
||||
FinalError::with_title("bzip3 error").detail(err.to_string()).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<zip::result::ZipError> for Error {
|
||||
fn from(err: zip::result::ZipError) -> Self {
|
||||
use zip::result::ZipError;
|
||||
|
@ -21,6 +21,7 @@ enum DirectoryExtension {
|
||||
Tar,
|
||||
Tbz,
|
||||
Tbz2,
|
||||
Tbz3,
|
||||
Tgz,
|
||||
Tlz4,
|
||||
Tlzma,
|
||||
@ -36,6 +37,7 @@ enum DirectoryExtension {
|
||||
enum FileExtension {
|
||||
Bz,
|
||||
Bz2,
|
||||
Bz3,
|
||||
Gz,
|
||||
Lz4,
|
||||
Lzma,
|
||||
|
Loading…
x
Reference in New Issue
Block a user