mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +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)
|
* [libbz2](https://www.sourceware.org/bzip2)
|
||||||
* [libbz3](https://github.com/kspalaiologos/bzip3)
|
* [libbz3](https://github.com/kspalaiologos/bzip3)
|
||||||
* [libz](https://www.zlib.net)
|
* [libz](https://www.zlib.net)
|
||||||
>>>>>>> 066184e (Add support for bzip3)
|
|
||||||
|
|
||||||
These should be available in your system's package manager.
|
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))),
|
level.map_or_else(Default::default, |l| bzip2::Compression::new((l as u32).clamp(1, 9))),
|
||||||
)),
|
)),
|
||||||
Bzip3 => Box::new(
|
Bzip3 => Box::new(
|
||||||
// Unwrap is safe when using a valid block size
|
// Use block size of 16 MiB
|
||||||
bzip3::write::Bz3Encoder::new(encoder, bytesize::ByteSize::mib(5).0 as usize).unwrap(),
|
bzip3::write::Bz3Encoder::new(encoder, 16 * 2_usize.pow(20))?,
|
||||||
),
|
),
|
||||||
Lz4 => Box::new(lz4_flex::frame::FrameEncoder::new(encoder).auto_finish()),
|
Lz4 => Box::new(lz4_flex::frame::FrameEncoder::new(encoder).auto_finish()),
|
||||||
Lzma => Box::new(xz2::write::XzEncoder::new(
|
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 {
|
impl From<zip::result::ZipError> for Error {
|
||||||
fn from(err: zip::result::ZipError) -> Self {
|
fn from(err: zip::result::ZipError) -> Self {
|
||||||
use zip::result::ZipError;
|
use zip::result::ZipError;
|
||||||
|
@ -21,6 +21,7 @@ enum DirectoryExtension {
|
|||||||
Tar,
|
Tar,
|
||||||
Tbz,
|
Tbz,
|
||||||
Tbz2,
|
Tbz2,
|
||||||
|
Tbz3,
|
||||||
Tgz,
|
Tgz,
|
||||||
Tlz4,
|
Tlz4,
|
||||||
Tlzma,
|
Tlzma,
|
||||||
@ -36,6 +37,7 @@ enum DirectoryExtension {
|
|||||||
enum FileExtension {
|
enum FileExtension {
|
||||||
Bz,
|
Bz,
|
||||||
Bz2,
|
Bz2,
|
||||||
|
Bz3,
|
||||||
Gz,
|
Gz,
|
||||||
Lz4,
|
Lz4,
|
||||||
Lzma,
|
Lzma,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user