my ass forgot to delete older files

This commit is contained in:
RabbyDevs 2025-05-04 17:31:09 +03:00
parent 5239d2cd98
commit 32485708a1

View file

@ -1,6 +1,6 @@
use std::path::PathBuf;
use std::{fs::create_dir_all, io::Write, path::Path};
use std::fs::{DirEntry, OpenOptions};
use std::fs::{remove_file, DirEntry, OpenOptions};
use directories::ProjectDirs;
use reqwest::blocking::Client;
@ -169,6 +169,7 @@ fn update_file_if_needed(dir: &Path, client: &Client, file_url: &str, file_type:
if let Some(file) = current_file {
if filename != file.file_name().into_string().unwrap().strip_prefix(format!("{}_", file_type).as_str()).unwrap() {
update_file(client, file_path, file_type, file_url)?;
remove_file(file.path()).unwrap();
} else {
eprintln!("{} file already exists at: {}", file_type, file.path().display());
}