diff options
author | fxqnlr <[email protected]> | 2023-05-29 18:01:12 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2023-05-29 18:01:12 +0200 |
commit | c7ecf3019a75dc0ab1a0aefeb9b880899fc8a231 (patch) | |
tree | 116075aaa57c35afca2749719d450c3cb473ab3e /src/files.rs | |
parent | 7755c9acf6b8a1d81c03ef1138e80a162f36e743 (diff) | |
download | modlist-c7ecf3019a75dc0ab1a0aefeb9b880899fc8a231.tar modlist-c7ecf3019a75dc0ab1a0aefeb9b880899fc8a231.tar.gz modlist-c7ecf3019a75dc0ab1a0aefeb9b880899fc8a231.zip |
cargo fmt and add fmt file
Diffstat (limited to 'src/files.rs')
-rw-r--r-- | src/files.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/files.rs b/src/files.rs index c81857b..3a16c62 100644 --- a/src/files.rs +++ b/src/files.rs | |||
@@ -92,7 +92,9 @@ async fn download_version( | |||
92 | let mut splitname: Vec<&str> = file.filename.split('.').collect(); | 92 | let mut splitname: Vec<&str> = file.filename.split('.').collect(); |
93 | let extension = match splitname.pop().ok_or("") { | 93 | let extension = match splitname.pop().ok_or("") { |
94 | Ok(e) => e, | 94 | Ok(e) => e, |
95 | Err(..) => return Err(MLError::new(ErrorType::Other, "NO_FILE_EXTENSION")), | 95 | Err(..) => { |
96 | return Err(MLError::new(ErrorType::Other, "NO_FILE_EXTENSION")) | ||
97 | } | ||
96 | }; | 98 | }; |
97 | let filename = format!( | 99 | let filename = format!( |
98 | "{}.mr.{}.{}.{}", | 100 | "{}.mr.{}.{}.{}", |
@@ -102,7 +104,8 @@ async fn download_version( | |||
102 | extension | 104 | extension |
103 | ); | 105 | ); |
104 | 106 | ||
105 | download_file(&file.url, &list.download_folder, &filename, &progress).await?; | 107 | download_file(&file.url, &list.download_folder, &filename, &progress) |
108 | .await?; | ||
106 | 109 | ||
107 | progress.set_message(format!("Copy {} to cache", version.id)); | 110 | progress.set_message(format!("Copy {} to cache", version.id)); |
108 | let dl_path_file = format!("{}/{}", list.download_folder, filename); | 111 | let dl_path_file = format!("{}/{}", list.download_folder, filename); |
@@ -119,7 +122,12 @@ async fn download_version( | |||
119 | Ok(()) | 122 | Ok(()) |
120 | } | 123 | } |
121 | 124 | ||
122 | async fn download_file(url: &str, path: &str, name: &str, progress: &ProgressBar) -> MLE<()> { | 125 | async fn download_file( |
126 | url: &str, | ||
127 | path: &str, | ||
128 | name: &str, | ||
129 | progress: &ProgressBar, | ||
130 | ) -> MLE<()> { | ||
123 | let dl_path_file = format!("{}/{}", path, name); | 131 | let dl_path_file = format!("{}/{}", path, name); |
124 | let res = Client::new().get(url).send().await?; | 132 | let res = Client::new().get(url).send().await?; |
125 | 133 | ||
@@ -185,7 +193,9 @@ pub fn get_file_path(list: &List, versionid: String) -> MLE<String> { | |||
185 | if path.is_file() { | 193 | if path.is_file() { |
186 | let pathstr = match path.to_str().ok_or("") { | 194 | let pathstr = match path.to_str().ok_or("") { |
187 | Ok(s) => s, | 195 | Ok(s) => s, |
188 | Err(..) => return Err(MLError::new(ErrorType::Other, "INVALID_PATH")), | 196 | Err(..) => { |
197 | return Err(MLError::new(ErrorType::Other, "INVALID_PATH")) | ||
198 | } | ||
189 | }; | 199 | }; |
190 | let namesplit: Vec<&str> = pathstr.split('.').collect(); | 200 | let namesplit: Vec<&str> = pathstr.split('.').collect(); |
191 | let ver_id = namesplit[namesplit.len() - 2]; | 201 | let ver_id = namesplit[namesplit.len() - 2]; |