diff --git a/src/commands/stone/create.rs b/src/commands/stone/create.rs index eb094ae..279d305 100644 --- a/src/commands/stone/create.rs +++ b/src/commands/stone/create.rs @@ -96,15 +96,15 @@ pub fn create_command( log_info(&format!("Processing storage device '{device_name}'.")); // Copy fwup template file if device has fwup build args - if let Some(build_args) = &device.build_args { - if let Some(template) = build_args.fwup_template() { - let input_path = input_dir.join(template); - let output_path = output_dir.join(template); - if let Err(e) = copy_file(&input_path, &output_path, verbose) { - errors.push(format!( - "Failed to copy fwup template '{template}' for device '{device_name}': {e}" - )); - } + if let Some(build_args) = &device.build_args + && let Some(template) = build_args.fwup_template() + { + let input_path = input_dir.join(template); + let output_path = output_dir.join(template); + if let Err(e) = copy_file(&input_path, &output_path, verbose) { + errors.push(format!( + "Failed to copy fwup template '{template}' for device '{device_name}': {e}" + )); } } @@ -192,15 +192,15 @@ fn process_image( log_info(&format!("Processing image '{image_name}'.")); // Copy fwup template file if image has fwup build args - if let Some(build_args) = image.build_args() { - if let Some(template) = build_args.fwup_template() { - let input_path = input_dir.join(template); - let output_path = output_dir.join(template); - if let Err(e) = copy_file(&input_path, &output_path, verbose) { - return Err(format!( - "Failed to copy fwup template '{template}' for image '{image_name}': {e}" - )); - } + if let Some(build_args) = image.build_args() + && let Some(template) = build_args.fwup_template() + { + let input_path = input_dir.join(template); + let output_path = output_dir.join(template); + if let Err(e) = copy_file(&input_path, &output_path, verbose) { + return Err(format!( + "Failed to copy fwup template '{template}' for image '{image_name}': {e}" + )); } } @@ -259,14 +259,14 @@ fn copy_file(input_path: &Path, output_path: &Path, verbose: bool) -> Result<(), } // Create output directory if it doesn't exist - if let Some(parent) = output_path.parent() { - if let Err(e) = fs::create_dir_all(parent) { - return Err(format!( - "Failed to create output directory '{}': {}", - parent.display(), - e - )); - } + if let Some(parent) = output_path.parent() + && let Err(e) = fs::create_dir_all(parent) + { + return Err(format!( + "Failed to create output directory '{}': {}", + parent.display(), + e + )); } // Copy the file diff --git a/src/commands/stone/provision.rs b/src/commands/stone/provision.rs index b6a92a7..8335a79 100644 --- a/src/commands/stone/provision.rs +++ b/src/commands/stone/provision.rs @@ -658,17 +658,17 @@ fn execute_provision_with_profile( verbose: bool, ) -> Result<(), String> { // First check for legacy provision script in runtime - if let Some(provision_file) = &manifest.runtime.provision { - if manifest.provision.is_none() { - log_info("Using legacy provision script from runtime.provision."); - return execute_provision_script( - provision_file, - input_dir, - build_dir, - verbose, - &HashMap::new(), - ); - } + if let Some(provision_file) = &manifest.runtime.provision + && manifest.provision.is_none() + { + log_info("Using legacy provision script from runtime.provision."); + return execute_provision_script( + provision_file, + input_dir, + build_dir, + verbose, + &HashMap::new(), + ); } // If no provision configuration exists, skip provision execution diff --git a/src/commands/stone/validate.rs b/src/commands/stone/validate.rs index 21faa78..95865bf 100644 --- a/src/commands/stone/validate.rs +++ b/src/commands/stone/validate.rs @@ -70,19 +70,18 @@ pub fn validate_command(manifest_path: &Path, input_dir: &Path) -> Result<(), St } // Check if provision_default references a valid profile - if let Some(default_profile_name) = &manifest.runtime.provision_default { - if manifest + if let Some(default_profile_name) = &manifest.runtime.provision_default + && manifest .get_provision_profile(default_profile_name) .is_none() - { - missing_provision_files.push(( - "Default profile reference".to_string(), - format!("Profile '{default_profile_name}' not found in provision.profiles"), - )); - } - // Note: We don't check if the default profile's script exists here - // because that will already be caught when validating all profiles above + { + missing_provision_files.push(( + "Default profile reference".to_string(), + format!("Profile '{default_profile_name}' not found in provision.profiles"), + )); } + // Note: We don't check if the default profile's script exists here + // because that will already be caught when validating all profiles above } else if manifest.runtime.provision_default.is_some() { missing_provision_files.push(( "Default profile reference".to_string(), @@ -93,12 +92,12 @@ pub fn validate_command(manifest_path: &Path, input_dir: &Path) -> Result<(), St // Process each storage device for (device_name, device) in &manifest.storage_devices { // Check fwup template file if device has fwup build args - if let Some(build_args) = &device.build_args { - if let Some(template) = build_args.fwup_template() { - let template_path = input_dir.join(template); - if !template_path.exists() { - missing_device_files.push((device_name.clone(), template.to_string())); - } + if let Some(build_args) = &device.build_args + && let Some(template) = build_args.fwup_template() + { + let template_path = input_dir.join(template); + if !template_path.exists() { + missing_device_files.push((device_name.clone(), template.to_string())); } } @@ -114,20 +113,18 @@ pub fn validate_command(manifest_path: &Path, input_dir: &Path) -> Result<(), St } // For fwup builds, check if template file exists - if let Some(build_type) = image.build() { - if build_type == "fwup" { - if let Some(build_args) = image.build_args() { - if let Some(template) = build_args.fwup_template() { - let template_path = input_dir.join(template); - if !template_path.exists() { - missing_files.push(( - device_name.clone(), - image_name.clone(), - template.to_string(), - )); - } - } - } + if let Some(build_type) = image.build() + && build_type == "fwup" + && let Some(build_args) = image.build_args() + && let Some(template) = build_args.fwup_template() + { + let template_path = input_dir.join(template); + if !template_path.exists() { + missing_files.push(( + device_name.clone(), + image_name.clone(), + template.to_string(), + )); } } diff --git a/src/fwup.rs b/src/fwup.rs index d5d1c0d..f0d88f6 100644 --- a/src/fwup.rs +++ b/src/fwup.rs @@ -58,14 +58,14 @@ pub fn create_firmware_package(options: &FwupOptions) -> Result<(), String> { } // Create output directory if it doesn't exist - if let Some(parent) = options.output_file.parent() { - if let Err(e) = std::fs::create_dir_all(parent) { - return Err(format!( - "Failed to create output directory '{}': {}", - parent.display(), - e - )); - } + if let Some(parent) = options.output_file.parent() + && let Err(e) = std::fs::create_dir_all(parent) + { + return Err(format!( + "Failed to create output directory '{}': {}", + parent.display(), + e + )); } // Build the fwup command