From d0ac4cf637cefae9146839ecbeb9b59a8306c231 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 29 Jul 2025 11:05:25 -0300 Subject: [PATCH] fix: reorder variable declarations to fix scope issue with meta_plugin_types Co-authored-by: aider (openai/andrew.openrouter.qwen.qwen3-coder) --- src/modes/save.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/modes/save.rs b/src/modes/save.rs index 3a810ef..45c0e6c 100644 --- a/src/modes/save.rs +++ b/src/modes/save.rs @@ -39,7 +39,16 @@ pub fn mode_save( let digest_type = cmd_args_digest_type(cmd, &args); debug!("MAIN: Digest type: {:?}", digest_type); - // Convert digest type to meta plugin type + let compression_type = cmd_args_compression_type(cmd, &args); + debug!("MAIN: Compression type: {:?}", compression_type); + let compression_engine = + get_compression_engine(compression_type.clone()).expect("Unable to get compression engine"); + + // Start with meta plugin types from command line + let mut meta_plugin_types: Vec = cmd_args_meta_plugin_types(cmd, &args); + debug!("MAIN: Meta plugin types: {:?}", meta_plugin_types); + + // Convert digest type to meta plugin type and add to the list if needed let digest_meta_plugin_type = match digest_type { crate::meta_plugin::MetaPluginType::DigestSha256 => Some(MetaPluginType::DigestSha256), crate::meta_plugin::MetaPluginType::DigestMd5 => Some(MetaPluginType::DigestMd5), @@ -48,17 +57,11 @@ pub fn mode_save( // Add digest meta plugin to the list if needed if let Some(digest_plugin_type) = digest_meta_plugin_type { - meta_plugin_types.push(digest_plugin_type); + if !meta_plugin_types.contains(&digest_plugin_type) { + meta_plugin_types.push(digest_plugin_type); + } } - let compression_type = cmd_args_compression_type(cmd, &args); - debug!("MAIN: Compression type: {:?}", compression_type); - let compression_engine = - get_compression_engine(compression_type.clone()).expect("Unable to get compression engine"); - - let meta_plugin_types: Vec = cmd_args_meta_plugin_types(cmd, &args); - debug!("MAIN: Meta plugin types: {:?}", meta_plugin_types); - // Initialize meta_plugins with MetaPlugin instances for each MetaPluginType let mut meta_plugins: Vec> = meta_plugin_types .into_iter()