fix some errors + warnings

This commit is contained in:
Antonios Barotsis 2024-03-12 02:32:03 +01:00 committed by João Marcos
parent 380893b6df
commit b04122a6de
9 changed files with 14 additions and 16 deletions

View File

@ -17,7 +17,6 @@ use crate::{
message::{MessageLevel, PrintMessage},
Bytes, EscapedPathDisplay, FileVisibilityPolicy,
},
warning,
};
pub fn compress_sevenz<W>(

View File

@ -19,7 +19,6 @@ use crate::{
message::{MessageLevel, PrintMessage},
Bytes, EscapedPathDisplay, FileVisibilityPolicy,
},
warning,
};
/// Unpacks the archive given by `archive` into the folder given by `into`.

View File

@ -24,7 +24,6 @@ use crate::{
message::{MessageLevel, PrintMessage},
pretty_format_list_of_paths, strip_cur_dir, Bytes, EscapedPathDisplay, FileVisibilityPolicy,
},
warning,
};
/// Unpacks the archive given by `archive` into the folder given by `output_folder`.

View File

@ -16,7 +16,7 @@ use crate::{
message::{MessageLevel, PrintMessage},
pretty_format_list_of_paths, try_infer_extension, user_wants_to_continue, EscapedPathDisplay,
},
warning, QuestionAction, QuestionPolicy, Result,
QuestionAction, QuestionPolicy, Result,
};
/// Check if the mime type matches the detected extensions.

View File

@ -113,7 +113,7 @@ pub fn compress_files(
}
Zip => {
if !formats.is_empty() {
warn_user_about_loading_zip_in_memory();
warn_user_about_loading_zip_in_memory(log_sender.clone());
if !user_wants_to_continue(output_path, question_policy, QuestionAction::Compression)? {
return Ok(false);
@ -142,7 +142,7 @@ pub fn compress_files(
}
SevenZip => {
if !formats.is_empty() {
warn_user_about_loading_sevenz_in_memory();
warn_user_about_loading_sevenz_in_memory(log_sender.clone());
if !user_wants_to_continue(output_path, question_policy, QuestionAction::Compression)? {
return Ok(false);

View File

@ -136,7 +136,7 @@ pub fn decompress_file(
}
Zip => {
if formats.len() > 1 {
warn_user_about_loading_zip_in_memory();
warn_user_about_loading_zip_in_memory(log_sender.clone());
if !user_wants_to_continue(input_file_path, question_policy, QuestionAction::Decompression)? {
return Ok(());
@ -193,7 +193,7 @@ pub fn decompress_file(
}
SevenZip => {
if formats.len() > 1 {
warn_user_about_loading_sevenz_in_memory();
warn_user_about_loading_sevenz_in_memory(log_sender.clone());
if !user_wants_to_continue(input_file_path, question_policy, QuestionAction::Decompression)? {
return Ok(());

View File

@ -1,6 +1,7 @@
use std::{
io::{self, BufReader, Read},
path::Path,
sync::mpsc::Sender,
};
use fs_err as fs;
@ -9,7 +10,7 @@ use crate::{
commands::warn_user_about_loading_zip_in_memory,
extension::CompressionFormat::{self, *},
list::{self, FileInArchive, ListOptions},
utils::user_wants_to_continue,
utils::{message::PrintMessage, user_wants_to_continue},
QuestionAction, QuestionPolicy, BUFFER_CAPACITY,
};
@ -20,6 +21,7 @@ pub fn list_archive_contents(
formats: Vec<CompressionFormat>,
list_options: ListOptions,
question_policy: QuestionPolicy,
log_sender: Sender<PrintMessage>,
) -> crate::Result<()> {
let reader = fs::File::open(archive_path)?;
@ -65,7 +67,7 @@ pub fn list_archive_contents(
Tar => Box::new(crate::archive::tar::list_archive(tar::Archive::new(reader))),
Zip => {
if formats.len() > 1 {
warn_user_about_loading_zip_in_memory();
warn_user_about_loading_zip_in_memory(log_sender.clone());
if !user_wants_to_continue(archive_path, question_policy, QuestionAction::Decompression)? {
return Ok(());
@ -94,7 +96,7 @@ pub fn list_archive_contents(
}
SevenZip => {
if formats.len() > 1 {
warn_user_about_loading_zip_in_memory();
warn_user_about_loading_zip_in_memory(log_sender.clone());
if !user_wants_to_continue(archive_path, question_policy, QuestionAction::Decompression)? {
return Ok(());
}

View File

@ -29,7 +29,7 @@ use crate::{
message::{MessageLevel, PrintMessage},
to_utf, EscapedPathDisplay, FileVisibilityPolicy,
},
warning, CliArgs, QuestionPolicy,
CliArgs, QuestionPolicy,
};
/// Warn the user that (de)compressing this .zip archive might freeze their system.
@ -41,7 +41,7 @@ fn warn_user_about_loading_zip_in_memory(log_sender: Sender<PrintMessage>) {
log_sender
.send(PrintMessage {
contents: format!("{}", ZIP_IN_MEMORY_LIMITATION_WARNING),
contents: ZIP_IN_MEMORY_LIMITATION_WARNING.to_string(),
accessible: true,
level: MessageLevel::Warning,
})
@ -57,7 +57,7 @@ fn warn_user_about_loading_sevenz_in_memory(log_sender: Sender<PrintMessage>) {
log_sender
.send(PrintMessage {
contents: format!("{}", SEVENZ_IN_MEMORY_LIMITATION_WARNING),
contents: SEVENZ_IN_MEMORY_LIMITATION_WARNING.to_string(),
accessible: true,
level: MessageLevel::Warning,
})
@ -323,7 +323,7 @@ pub fn run(
println!();
}
let formats = extension::flatten_compression_formats(&formats);
list_archive_contents(archive_path, formats, list_options, question_policy)?;
list_archive_contents(archive_path, formats, list_options, question_policy, log_sender.clone())?;
}
}
}

View File

@ -8,7 +8,6 @@ use self::CompressionFormat::*;
use crate::{
error::Error,
utils::message::{MessageLevel, PrintMessage},
warning,
};
pub const SUPPORTED_EXTENSIONS: &[&str] = &[