From 87535fb8393a545aecfa825e2fc63cb39740669c Mon Sep 17 00:00:00 2001 From: mxve <68632137+mxve@users.noreply.github.com> Date: Fri, 1 Mar 2024 10:37:56 +0100 Subject: [PATCH] add delete support for dirs --- src/main.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 15558a1..2c1d910 100644 --- a/src/main.rs +++ b/src/main.rs @@ -412,7 +412,7 @@ async fn update( for f in game.delete.iter() { let file_path = dir.join(f); - if file_path.exists() { + if file_path.is_file() { if fs::remove_file(&file_path).is_err() { println!( "[{}] Couldn't delete {}", @@ -426,6 +426,20 @@ async fn update( misc::cute_path(&file_path) ); } + } else if file_path.is_dir() { + if fs::remove_dir_all(&file_path).is_err() { + println!( + "[{}] Couldn't delete {}", + "Error".bright_red(), + misc::cute_path(&file_path) + ); + } else { + println!( + "[{}] {}", + "Removed".bright_red(), + misc::cute_path(&file_path) + ); + } } }