From 536a5d0a5983782a91a27711516f1c32a078ae69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Wed, 27 Mar 2024 14:04:40 +0100 Subject: [PATCH] Clippy fixes --- flake-ctl/src/app.rs | 2 +- flake-ctl/src/app_config.rs | 2 ++ flake-ctl/src/main.rs | 24 ++++++++++-------------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/flake-ctl/src/app.rs b/flake-ctl/src/app.rs index fcc480a..545e40a 100644 --- a/flake-ctl/src/app.rs +++ b/flake-ctl/src/app.rs @@ -273,7 +273,7 @@ pub fn remove(app: &str, engine: &str, silent: bool) -> bool { } } } - return true + true } pub fn basename(program_path: &String) -> String { diff --git a/flake-ctl/src/app_config.rs b/flake-ctl/src/app_config.rs index 54edcd2..7156314 100644 --- a/flake-ctl/src/app_config.rs +++ b/flake-ctl/src/app_config.rs @@ -168,6 +168,7 @@ impl AppConfig { let config = std::fs::OpenOptions::new() .write(true) .create(true) + .truncate(true) .open(config_file) .unwrap_or_else(|_| panic!("Failed to open {:?}", config_file)); serde_yaml::to_writer(config, &yaml_config).unwrap(); @@ -304,6 +305,7 @@ impl AppConfig { let config = std::fs::OpenOptions::new() .write(true) .create(true) + .truncate(true) .open(config_file) .unwrap_or_else(|_| panic!("Failed to open {:?}", config_file)); serde_yaml::to_writer(config, &yaml_config).unwrap(); diff --git a/flake-ctl/src/main.rs b/flake-ctl/src/main.rs index 3138d69..160160f 100644 --- a/flake-ctl/src/main.rs +++ b/flake-ctl/src/main.rs @@ -113,13 +113,11 @@ async fn main() -> Result> { }, // remove cli::Firecracker::Remove { vm, app } => { - if ! app.is_none() { - if ! app::remove( - app.as_ref().map(String::as_str).unwrap(), - defaults::FIRECRACKER_PILOT, false - ) { - return Ok(ExitCode::FAILURE) - } + if ! app.is_none() && ! app::remove( + app.as_ref().map(String::as_str).unwrap(), + defaults::FIRECRACKER_PILOT, false + ) { + return Ok(ExitCode::FAILURE) } if ! vm.is_none() { app::purge( @@ -182,13 +180,11 @@ async fn main() -> Result> { }, // remove cli::Podman::Remove { container, app } => { - if ! app.is_none() { - if ! app::remove( - app.as_ref().map(String::as_str).unwrap(), - defaults::PODMAN_PILOT, false - ) { - return Ok(ExitCode::FAILURE) - } + if ! app.is_none() && ! app::remove( + app.as_ref().map(String::as_str).unwrap(), + defaults::PODMAN_PILOT, false + ) { + return Ok(ExitCode::FAILURE) } if ! container.is_none() { app::purge(