From caaf73e9f38c270359fcbdb9d3695bcdb6d212c6 Mon Sep 17 00:00:00 2001 From: mxve <68632137+mxve@users.noreply.github.com> Date: Tue, 2 Jan 2024 11:22:18 +0100 Subject: [PATCH] add support for Game.delete --- src/main.rs | 19 +++++++++++++++++++ src/structs.rs | 1 + 2 files changed, 20 insertions(+) diff --git a/src/main.rs b/src/main.rs index 91c8657..0c09778 100644 --- a/src/main.rs +++ b/src/main.rs @@ -358,6 +358,25 @@ async fn update(game: &Game<'_>, dir: &Path, bonus_content: bool, force: bool) { pb.finish(); + for f in game.delete.iter() { + let file_path = dir.join(f); + if file_path.exists() { + if let Err(_) = fs::remove_file(&file_path) { + println!( + "[{}] Couldn't delete {}", + "Error".bright_red(), + misc::cute_path(&file_path) + ); + } else { + println!( + "[{}] {}", + "Removed".bright_red(), + misc::cute_path(&file_path) + ); + } + } + } + let mut hash_file_content = String::new(); for (file, hash) in hashes.iter() { hash_file_content.push_str(&format!("{} {}\n", hash, file)); diff --git a/src/structs.rs b/src/structs.rs index db9d622..074a8d8 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -12,6 +12,7 @@ pub struct Game<'a> { pub references: Vec<&'a str>, pub app_id: u32, pub bonus: Vec<&'a str>, + pub delete: Vec<&'a str>, } #[derive(serde::Deserialize, serde::Serialize)]