summaryrefslogtreecommitdiff
path: root/src/files.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2022-12-03 20:08:42 +0100
committerFxQnLr <[email protected]>2022-12-03 20:08:42 +0100
commitf3f746be6c1c19c93d440bbc210dec631e2b42bb (patch)
tree562531a2929cc5f58f449652220a0abe94a0dec7 /src/files.rs
parent575d2493e8e5747bf65321f7277e52211d73e387 (diff)
downloadmodlist-f3f746be6c1c19c93d440bbc210dec631e2b42bb.tar
modlist-f3f746be6c1c19c93d440bbc210dec631e2b42bb.tar.gz
modlist-f3f746be6c1c19c93d440bbc210dec631e2b42bb.zip
remove mod start
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)? {