summaryrefslogtreecommitdiff
path: root/src/files.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/files.rs')
-rw-r--r--src/files.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/files.rs b/src/files.rs
index 1c0b13c..2c5994d 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -1,4 +1,4 @@
1use std::{fs::{File, read_dir}, io::Write, collections::HashMap}; 1use std::{fs::{File, read_dir, remove_file}, io::Write, collections::HashMap};
2use futures_util::StreamExt; 2use futures_util::StreamExt;
3use reqwest::Client; 3use reqwest::Client;
4 4
@@ -24,6 +24,14 @@ pub async fn download_file(url: String, path: String, name: String) -> Result<()
24 Ok(()) 24 Ok(())
25} 25}
26 26
27pub fn delete_version(list: List, version: String) -> Result<(), Box<dyn std::error::Error>> {
28 let file = get_file_path(list, version)?;
29
30 remove_file(file)?;
31
32 Ok(())
33}
34
27pub fn get_file_path(list: List, versionid: String) -> Result<String, Box<dyn std::error::Error>> { 35pub fn get_file_path(list: List, versionid: String) -> Result<String, Box<dyn std::error::Error>> {
28 let mut names: HashMap<String, String> = HashMap::new(); 36 let mut names: HashMap<String, String> = HashMap::new();
29 for file in read_dir(list.download_folder)? { 37 for file in read_dir(list.download_folder)? {