add delete support for dirs
This commit is contained in:
parent
4d6f056d7b
commit
87535fb839
16
src/main.rs
16
src/main.rs
@ -412,7 +412,7 @@ async fn update(
|
|||||||
|
|
||||||
for f in game.delete.iter() {
|
for f in game.delete.iter() {
|
||||||
let file_path = dir.join(f);
|
let file_path = dir.join(f);
|
||||||
if file_path.exists() {
|
if file_path.is_file() {
|
||||||
if fs::remove_file(&file_path).is_err() {
|
if fs::remove_file(&file_path).is_err() {
|
||||||
println!(
|
println!(
|
||||||
"[{}] Couldn't delete {}",
|
"[{}] Couldn't delete {}",
|
||||||
@ -426,6 +426,20 @@ async fn update(
|
|||||||
misc::cute_path(&file_path)
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user