mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
fix(archive): return result in list_archive functions
This commit is contained in:
parent
39cef75dfe
commit
56f69e19a3
@ -54,7 +54,7 @@ pub fn unpack_archive(reader: Box<dyn Read>, output_folder: &Path, quiet: bool)
|
|||||||
/// List contents of `archive`, returning a vector of archive entries
|
/// List contents of `archive`, returning a vector of archive entries
|
||||||
pub fn list_archive(
|
pub fn list_archive(
|
||||||
mut archive: tar::Archive<impl Read + Send + 'static>,
|
mut archive: tar::Archive<impl Read + Send + 'static>,
|
||||||
) -> impl Iterator<Item = crate::Result<FileInArchive>> {
|
) -> crate::Result<impl Iterator<Item = crate::Result<FileInArchive>>> {
|
||||||
struct Files(Receiver<crate::Result<FileInArchive>>);
|
struct Files(Receiver<crate::Result<FileInArchive>>);
|
||||||
impl Iterator for Files {
|
impl Iterator for Files {
|
||||||
type Item = crate::Result<FileInArchive>;
|
type Item = crate::Result<FileInArchive>;
|
||||||
@ -77,7 +77,7 @@ pub fn list_archive(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Files(rx)
|
Ok(Files(rx))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compresses the archives given by `input_filenames` into the file given previously to `writer`.
|
/// Compresses the archives given by `input_filenames` into the file given previously to `writer`.
|
||||||
|
@ -106,7 +106,7 @@ where
|
|||||||
pub fn list_archive<R>(
|
pub fn list_archive<R>(
|
||||||
mut archive: ZipArchive<R>,
|
mut archive: ZipArchive<R>,
|
||||||
password: Option<&[u8]>,
|
password: Option<&[u8]>,
|
||||||
) -> impl Iterator<Item = crate::Result<FileInArchive>>
|
) -> crate::Result<impl Iterator<Item = crate::Result<FileInArchive>>>
|
||||||
where
|
where
|
||||||
R: Read + Seek + Send + 'static,
|
R: Read + Seek + Send + 'static,
|
||||||
{
|
{
|
||||||
@ -146,7 +146,7 @@ where
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Files(rx)
|
Ok(Files(rx))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compresses the archives given by `input_filenames` into the file given previously to `writer`.
|
/// Compresses the archives given by `input_filenames` into the file given previously to `writer`.
|
||||||
|
@ -34,7 +34,7 @@ pub fn list_archive_contents(
|
|||||||
// Any other Zip decompression done can take up the whole RAM and freeze ouch.
|
// Any other Zip decompression done can take up the whole RAM and freeze ouch.
|
||||||
if let &[Zip] = formats.as_slice() {
|
if let &[Zip] = formats.as_slice() {
|
||||||
let zip_archive = zip::ZipArchive::new(reader)?;
|
let zip_archive = zip::ZipArchive::new(reader)?;
|
||||||
let files = crate::archive::zip::list_archive(zip_archive, password);
|
let files = crate::archive::zip::list_archive(zip_archive, password)?;
|
||||||
list::list_files(archive_path, files, list_options)?;
|
list::list_files(archive_path, files, list_options)?;
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -64,7 +64,7 @@ pub fn list_archive_contents(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let files: Box<dyn Iterator<Item = crate::Result<FileInArchive>>> = match formats[0] {
|
let files: Box<dyn Iterator<Item = crate::Result<FileInArchive>>> = match formats[0] {
|
||||||
Tar => Box::new(crate::archive::tar::list_archive(tar::Archive::new(reader))),
|
Tar => Box::new(crate::archive::tar::list_archive(tar::Archive::new(reader))?),
|
||||||
Zip => {
|
Zip => {
|
||||||
if formats.len() > 1 {
|
if formats.len() > 1 {
|
||||||
// Locking necessary to guarantee that warning and question
|
// Locking necessary to guarantee that warning and question
|
||||||
@ -81,7 +81,7 @@ pub fn list_archive_contents(
|
|||||||
io::copy(&mut reader, &mut vec)?;
|
io::copy(&mut reader, &mut vec)?;
|
||||||
let zip_archive = zip::ZipArchive::new(io::Cursor::new(vec))?;
|
let zip_archive = zip::ZipArchive::new(io::Cursor::new(vec))?;
|
||||||
|
|
||||||
Box::new(crate::archive::zip::list_archive(zip_archive, password))
|
Box::new(crate::archive::zip::list_archive(zip_archive, password)?)
|
||||||
}
|
}
|
||||||
#[cfg(feature = "unrar")]
|
#[cfg(feature = "unrar")]
|
||||||
Rar => {
|
Rar => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user