mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 20:15:27 +00:00
Fix error message panic when cannot list non-archive files
This commit is contained in:
parent
7f97715d34
commit
162e1c1259
@ -227,17 +227,12 @@ pub fn run(args: Opts, question_policy: QuestionPolicy) -> crate::Result<()> {
|
|||||||
.map(|(path, _)| path.clone())
|
.map(|(path, _)| path.clone())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Error
|
|
||||||
if !not_archives.is_empty() {
|
if !not_archives.is_empty() {
|
||||||
eprintln!("Some file you asked ouch to list the contents of is not an archive.");
|
let error = FinalError::with_title("Cannot list archive contents")
|
||||||
for file in ¬_archives {
|
.detail("Only archives can have their contents listed")
|
||||||
eprintln!("Could not list {}.", to_utf(file));
|
.detail(format!("Files are not archives: {}", concatenate_os_str_list(¬_archives)));
|
||||||
}
|
|
||||||
todo!(
|
return Err(error.into());
|
||||||
"Dev note: add this error variant and pass the Vec to it, all the files \
|
|
||||||
lacking extension shall be shown: {:#?}.",
|
|
||||||
not_archives
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let list_options = ListOptions { tree };
|
let list_options = ListOptions { tree };
|
||||||
@ -330,7 +325,6 @@ fn decompress_file(
|
|||||||
file_name: &Path,
|
file_name: &Path,
|
||||||
question_policy: QuestionPolicy,
|
question_policy: QuestionPolicy,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
// TODO: improve error message
|
|
||||||
let reader = fs::File::open(&input_file_path)?;
|
let reader = fs::File::open(&input_file_path)?;
|
||||||
|
|
||||||
// Output path is used by single file formats
|
// Output path is used by single file formats
|
||||||
@ -426,7 +420,6 @@ fn list_archive_contents(
|
|||||||
formats: Vec<CompressionFormat>,
|
formats: Vec<CompressionFormat>,
|
||||||
list_options: ListOptions,
|
list_options: ListOptions,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
// TODO: improve error message
|
|
||||||
let reader = fs::File::open(&archive_path)?;
|
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 it's logic separated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user