diff --git a/src/archive/sevenz.rs b/src/archive/sevenz.rs index 2c5135a..0a00226 100644 --- a/src/archive/sevenz.rs +++ b/src/archive/sevenz.rs @@ -17,7 +17,6 @@ use crate::{ message::{MessageLevel, PrintMessage}, Bytes, EscapedPathDisplay, FileVisibilityPolicy, }, - warning, }; pub fn compress_sevenz( diff --git a/src/archive/tar.rs b/src/archive/tar.rs index c89db5d..5e884c4 100644 --- a/src/archive/tar.rs +++ b/src/archive/tar.rs @@ -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`. diff --git a/src/archive/zip.rs b/src/archive/zip.rs index 0df03ce..84c45b6 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -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`. diff --git a/src/check.rs b/src/check.rs index 1d25cb8..a46815f 100644 --- a/src/check.rs +++ b/src/check.rs @@ -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. diff --git a/src/commands/compress.rs b/src/commands/compress.rs index ee02981..bc2f259 100644 --- a/src/commands/compress.rs +++ b/src/commands/compress.rs @@ -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); diff --git a/src/commands/decompress.rs b/src/commands/decompress.rs index 697d589..97b938b 100644 --- a/src/commands/decompress.rs +++ b/src/commands/decompress.rs @@ -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(()); diff --git a/src/commands/list.rs b/src/commands/list.rs index 05e37c3..c394179 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -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, list_options: ListOptions, question_policy: QuestionPolicy, + log_sender: Sender, ) -> 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(()); } diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 7379bf4..e1d90fc 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -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) { 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) { 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())?; } } } diff --git a/src/extension.rs b/src/extension.rs index 782edf2..612afcc 100644 --- a/src/extension.rs +++ b/src/extension.rs @@ -8,7 +8,6 @@ use self::CompressionFormat::*; use crate::{ error::Error, utils::message::{MessageLevel, PrintMessage}, - warning, }; pub const SUPPORTED_EXTENSIONS: &[&str] = &[