diff options
Diffstat (limited to 'src/files.rs')
-rw-r--r-- | src/files.rs | 10 |
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 @@ | |||
1 | use std::{fs::{File, read_dir}, io::Write, collections::HashMap}; | 1 | use std::{fs::{File, read_dir, remove_file}, io::Write, collections::HashMap}; |
2 | use futures_util::StreamExt; | 2 | use futures_util::StreamExt; |
3 | use reqwest::Client; | 3 | use 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 | ||
27 | pub 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 | |||
27 | pub fn get_file_path(list: List, versionid: String) -> Result<String, Box<dyn std::error::Error>> { | 35 | pub 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)? { |