diff options
Diffstat (limited to 'src/files.rs')
-rw-r--r-- | src/files.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/files.rs b/src/files.rs index 59fc7de..a4c128e 100644 --- a/src/files.rs +++ b/src/files.rs | |||
@@ -18,7 +18,7 @@ use crate::{ | |||
18 | pub async fn download_versions(list: List, config: Cfg, versions: Vec<Version>) -> MLE<String> { | 18 | pub async fn download_versions(list: List, config: Cfg, versions: Vec<Version>) -> MLE<String> { |
19 | let mut cached = get_cached_versions(&config.cache); | 19 | let mut cached = get_cached_versions(&config.cache); |
20 | 20 | ||
21 | println!("{:#?}", cached); | 21 | // println!("{:#?}", cached); |
22 | 22 | ||
23 | let dl_path = String::from(&list.download_folder); | 23 | let dl_path = String::from(&list.download_folder); |
24 | 24 | ||
@@ -42,8 +42,12 @@ pub async fn download_versions(list: List, config: Cfg, versions: Vec<Version>) | |||
42 | print!("\t└({})Download version {}", project_info.title, ver.id); | 42 | print!("\t└({})Download version {}", project_info.title, ver.id); |
43 | //Force flush of stdout, else print! doesn't print instantly | 43 | //Force flush of stdout, else print! doesn't print instantly |
44 | std::io::stdout().flush().unwrap(); | 44 | std::io::stdout().flush().unwrap(); |
45 | let primary_file = ver.files.into_iter().find(|file| file.primary).unwrap(); | 45 | let files = ver.files; |
46 | let mut splitname: Vec<&str> = primary_file.filename.split('.').collect(); | 46 | let file = match files.clone().into_iter().find(|f| f.primary) { |
47 | Some(f) => f, | ||
48 | None => files[0].clone() | ||
49 | }; | ||
50 | let mut splitname: Vec<&str> = file.filename.split('.').collect(); | ||
47 | let extension = match splitname.pop().ok_or("") { | 51 | let extension = match splitname.pop().ok_or("") { |
48 | Ok(e) => e, | 52 | Ok(e) => e, |
49 | Err(..) => return Err(MLError::new(ErrorType::Other, "NO_FILE_EXTENSION")), | 53 | Err(..) => return Err(MLError::new(ErrorType::Other, "NO_FILE_EXTENSION")), |
@@ -56,7 +60,7 @@ pub async fn download_versions(list: List, config: Cfg, versions: Vec<Version>) | |||
56 | extension | 60 | extension |
57 | ); | 61 | ); |
58 | download_file( | 62 | download_file( |
59 | primary_file.url, | 63 | file.url, |
60 | list.clone().download_folder, | 64 | list.clone().download_folder, |
61 | filename.clone(), | 65 | filename.clone(), |
62 | ) | 66 | ) |