Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/commands/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
QuestionAction, QuestionPolicy, BUFFER_CAPACITY,
};

/// File at input_file_path is opened for reading, example: "archive.tar.gz"
/// File at archive_path is opened for reading, example: "archive.tar.gz"
/// formats contains each format necessary for decompression, example: [Gz, Tar] (in decompression order)
pub fn list_archive_contents(
archive_path: &Path,
Expand All @@ -25,7 +25,7 @@ pub fn list_archive_contents(
) -> crate::Result<()> {
let reader = fs::File::open(archive_path)?;

// Zip archives are special, because they require io::Seek, so it requires it's logic separated
// Zip archives are special, because they require io::Seek, so it requires its logic separated
// from decoder chaining.
//
// This is the only case where we can read and unpack it directly, without having to do
Expand Down Expand Up @@ -128,12 +128,14 @@ pub fn list_archive_contents(
if !user_wants_to_continue(archive_path, question_policy, QuestionAction::Decompression)? {
return Ok(());
}
}

let mut vec = vec![];
io::copy(&mut reader, &mut vec)?;
let mut vec = vec![];
io::copy(&mut reader, &mut vec)?;

Box::new(archive::sevenz::list_archive(io::Cursor::new(vec), password)?)
Box::new(archive::sevenz::list_archive(io::Cursor::new(vec), password)?)
} else {
// If it's the only format, we can read the archive directly.
Box::new(archive::sevenz::list_archive(fs::File::open(archive_path)?, password)?)
}
}
Gzip | Bzip | Bzip3 | Lz4 | Lzma | Xz | Lzip | Snappy | Zstd | Brotli => {
unreachable!("Not an archive, should be validated before calling this function.");
Expand Down
Loading