mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-05 02:55:31 +00:00
style: cargo fmt
This commit is contained in:
parent
84f1ec4daf
commit
f8f1439ec5
@ -55,14 +55,17 @@ pub fn list_archive(
|
||||
};
|
||||
|
||||
let result = match archive.open_for_listing() {
|
||||
Ok(iter) => iter.map(|item| {
|
||||
let item = item?;
|
||||
let is_dir = item.is_directory();
|
||||
let path = item.filename;
|
||||
Ok(iter) => iter
|
||||
.map(|item| {
|
||||
let item = item?;
|
||||
let is_dir = item.is_directory();
|
||||
let path = item.filename;
|
||||
|
||||
Ok(FileInArchive { path, is_dir })
|
||||
}).collect::<Vec<_>>().into_iter(),
|
||||
Err(e) => return Err(Error::UnrarError{reason: e.to_string()}),
|
||||
Ok(FileInArchive { path, is_dir })
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter(),
|
||||
Err(e) => return Err(Error::UnrarError { reason: e.to_string() }),
|
||||
};
|
||||
|
||||
Ok(result)
|
||||
|
@ -12,7 +12,7 @@ use same_file::Handle;
|
||||
use sevenz_rust::SevenZArchiveEntry;
|
||||
|
||||
use crate::{
|
||||
error::FinalError,
|
||||
error::{Error, FinalError},
|
||||
list::FileInArchive,
|
||||
utils::{
|
||||
self, cd_into_same_dir_as,
|
||||
@ -20,7 +20,6 @@ use crate::{
|
||||
Bytes, EscapedPathDisplay, FileVisibilityPolicy,
|
||||
},
|
||||
};
|
||||
use crate::error::Error;
|
||||
|
||||
pub fn compress_sevenz<W>(
|
||||
files: &[PathBuf],
|
||||
@ -100,12 +99,7 @@ where
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
pub fn decompress_sevenz<R>(
|
||||
reader: R,
|
||||
output_path: &Path,
|
||||
password: Option<&[u8]>,
|
||||
quiet: bool,
|
||||
) -> crate::Result<usize>
|
||||
pub fn decompress_sevenz<R>(reader: R, output_path: &Path, password: Option<&[u8]>, quiet: bool) -> crate::Result<usize>
|
||||
where
|
||||
R: Read + Seek,
|
||||
{
|
||||
@ -166,8 +160,8 @@ where
|
||||
Some(password) => sevenz_rust::decompress_with_extract_fn_and_password(
|
||||
reader,
|
||||
output_path,
|
||||
sevenz_rust::Password::from(password.to_str().map_err(|_| {
|
||||
Error::InvalidPassword{reason: "7z requires that all passwords are valid UTF-8".to_string()}
|
||||
sevenz_rust::Password::from(password.to_str().map_err(|_| Error::InvalidPassword {
|
||||
reason: "7z requires that all passwords are valid UTF-8".to_string(),
|
||||
})?),
|
||||
entry_extract_fn,
|
||||
)?,
|
||||
@ -198,7 +192,11 @@ pub fn list_archive(
|
||||
Some(password) => {
|
||||
let password = match password.to_str() {
|
||||
Ok(p) => p,
|
||||
Err(err) => return Err(Error::InvalidPassword{ reason: err.to_string()}),
|
||||
Err(err) => {
|
||||
return Err(Error::InvalidPassword {
|
||||
reason: err.to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
sevenz_rust::decompress_with_extract_fn_and_password(
|
||||
reader,
|
||||
@ -206,7 +204,7 @@ pub fn list_archive(
|
||||
sevenz_rust::Password::from(password),
|
||||
entry_extract_fn,
|
||||
)
|
||||
},
|
||||
}
|
||||
None => sevenz_rust::decompress_with_extract_fn(reader, ".", entry_extract_fn),
|
||||
};
|
||||
|
||||
|
@ -5,9 +5,10 @@ mod decompress;
|
||||
mod list;
|
||||
|
||||
use std::{ops::ControlFlow, path::PathBuf};
|
||||
|
||||
use bstr::ByteSlice;
|
||||
use rayon::prelude::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
|
||||
use utils::colors;
|
||||
use bstr::ByteSlice;
|
||||
|
||||
use crate::{
|
||||
check,
|
||||
@ -188,7 +189,9 @@ pub fn run(
|
||||
output_file_path,
|
||||
question_policy,
|
||||
args.quiet,
|
||||
args.password.as_deref().map(|str| <[u8] as ByteSlice>::from_os_str(str).expect("convert password to bytes failed")),
|
||||
args.password.as_deref().map(|str| {
|
||||
<[u8] as ByteSlice>::from_os_str(str).expect("convert password to bytes failed")
|
||||
}),
|
||||
)
|
||||
})
|
||||
}
|
||||
@ -227,7 +230,9 @@ pub fn run(
|
||||
formats,
|
||||
list_options,
|
||||
question_policy,
|
||||
args.password.as_deref().map(|str| <[u8] as ByteSlice>::from_os_str(str).expect("convert password to bytes failed")),
|
||||
args.password
|
||||
.as_deref()
|
||||
.map(|str| <[u8] as ByteSlice>::from_os_str(str).expect("convert password to bytes failed")),
|
||||
)?;
|
||||
}
|
||||
|
||||
|
@ -152,8 +152,8 @@ impl fmt::Display for Error {
|
||||
Error::UnsupportedFormat { reason } => {
|
||||
FinalError::with_title("Recognised but unsupported format").detail(reason.clone())
|
||||
}
|
||||
Error::InvalidPassword{reason} => FinalError::with_title("Invalid password").detail(reason.clone()),
|
||||
Error::UnrarError{reason} => FinalError::with_title("Unrar error").detail(reason.clone()),
|
||||
Error::InvalidPassword { reason } => FinalError::with_title("Invalid password").detail(reason.clone()),
|
||||
Error::UnrarError { reason } => FinalError::with_title("Unrar error").detail(reason.clone()),
|
||||
};
|
||||
|
||||
write!(f, "{err}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user