summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cache.rs2
-rw-r--r--src/commands/modification.rs16
-rw-r--r--src/files.rs12
-rw-r--r--src/main.rs1
4 files changed, 19 insertions, 12 deletions
diff --git a/src/cache.rs b/src/cache.rs
index 11645d1..c928670 100644
--- a/src/cache.rs
+++ b/src/cache.rs
@@ -31,7 +31,7 @@ pub fn get_cached_versions(path: &str) -> HashMap<String, String> {
31/// Panics if . 31/// Panics if .
32pub fn copy_cached_version(version_path: &str, download_path: &str) { 32pub fn copy_cached_version(version_path: &str, download_path: &str) {
33 let versplit: Vec<&str> = version_path.split('/').collect(); 33 let versplit: Vec<&str> = version_path.split('/').collect();
34 let download = format!("{}{}", download_path, versplit[versplit.len() - 1]); 34 let download = format!("{}/{}", download_path, versplit[versplit.len() - 1]);
35 // println!("{:#?}", download); 35 // println!("{:#?}", download);
36 copy(version_path, download).unwrap(); 36 copy(version_path, download).unwrap();
37} 37}
diff --git a/src/commands/modification.rs b/src/commands/modification.rs
index ffc4e10..67cde0b 100644
--- a/src/commands/modification.rs
+++ b/src/commands/modification.rs
@@ -159,16 +159,20 @@ async fn get_mod_infos(config: Cfg, mod_ids: Vec<String>, list: List) -> MLE<Vec
159 .find(|v| v.id == current_id) 159 .find(|v| v.id == current_id)
160 .unwrap(), 160 .unwrap(),
161 ); 161 );
162 162
163 file = current_version 163 // match primary, if none?
164 let files = current_version
164 .clone() 165 .clone()
165 .ok_or("") 166 .ok_or("")
166 .unwrap() 167 .unwrap()
167 .files 168 .files;
168 .into_iter() 169
169 .find(|f| f.primary) 170 file = match files.clone().into_iter().find(|f| f.primary) {
170 .unwrap() 171 Some(f) => f,
172 None => { files[0].clone() }
173 }
171 .url; 174 .url;
175
172 for ver in available_versions { 176 for ver in available_versions {
173 available_versions_vec.push(ver.id); 177 available_versions_vec.push(ver.id);
174 } 178 }
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::{
18pub async fn download_versions(list: List, config: Cfg, versions: Vec<Version>) -> MLE<String> { 18pub 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 )
diff --git a/src/main.rs b/src/main.rs
index 0ecb850..53cbe71 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -148,7 +148,6 @@ async fn main() {
148 let cli = Cli::parse(); 148 let cli = Cli::parse();
149 149
150 let config = Cfg::init(cli.config).unwrap(); 150 let config = Cfg::init(cli.config).unwrap();
151 println!("{:?}", config);
152 151
153 match cli.command { 152 match cli.command {
154 Commands::Mod { command } => { 153 Commands::Mod { command } => {