diff options
Diffstat (limited to 'src/commands/download.rs')
-rw-r--r-- | src/commands/download.rs | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/commands/download.rs b/src/commands/download.rs index dd00ffb..a7cf744 100644 --- a/src/commands/download.rs +++ b/src/commands/download.rs | |||
@@ -5,7 +5,8 @@ use crate::{ | |||
5 | db::userlist_get_all_current_versions_with_mods, | 5 | db::userlist_get_all_current_versions_with_mods, |
6 | error::{ErrorType, MLError, MLE}, | 6 | error::{ErrorType, MLError, MLE}, |
7 | files::{ | 7 | files::{ |
8 | clean_list_dir, delete_version, disable_version, download_versions, get_downloaded_versions, | 8 | clean_list_dir, delete_version, disable_version, download_versions, |
9 | get_downloaded_versions, | ||
9 | }, | 10 | }, |
10 | modrinth::get_raw_versions, | 11 | modrinth::get_raw_versions, |
11 | }; | 12 | }; |
@@ -18,7 +19,8 @@ pub async fn download( | |||
18 | delete_old: bool, | 19 | delete_old: bool, |
19 | ) -> MLE<()> { | 20 | ) -> MLE<()> { |
20 | let mp = MultiProgress::new(); | 21 | let mp = MultiProgress::new(); |
21 | let download_p = mp.add(ProgressBar::new(liststack.len().try_into().unwrap())); | 22 | let download_p = |
23 | mp.add(ProgressBar::new(liststack.len().try_into().unwrap())); | ||
22 | download_p.set_style( | 24 | download_p.set_style( |
23 | ProgressStyle::with_template(STYLE_BAR_POS) | 25 | ProgressStyle::with_template(STYLE_BAR_POS) |
24 | .unwrap() | 26 | .unwrap() |
@@ -28,14 +30,19 @@ pub async fn download( | |||
28 | for current_list in liststack { | 30 | for current_list in liststack { |
29 | download_p.set_message(format!("Download in {}", current_list.id)); | 31 | download_p.set_message(format!("Download in {}", current_list.id)); |
30 | 32 | ||
31 | let downloaded_versions = get_downloaded_versions(current_list.clone())?; | 33 | let downloaded_versions = |
32 | let current_version_ids = match userlist_get_all_current_versions_with_mods( | 34 | get_downloaded_versions(current_list.clone())?; |
33 | config, | 35 | let current_version_ids = |
34 | String::from(¤t_list.id), | 36 | match userlist_get_all_current_versions_with_mods( |
35 | ) { | 37 | config, |
36 | Ok(i) => Ok(i), | 38 | String::from(¤t_list.id), |
37 | Err(e) => Err(MLError::new(ErrorType::DBError, e.to_string().as_str())), | 39 | ) { |
38 | }?; | 40 | Ok(i) => Ok(i), |
41 | Err(e) => Err(MLError::new( | ||
42 | ErrorType::DBError, | ||
43 | e.to_string().as_str(), | ||
44 | )), | ||
45 | }?; | ||
39 | 46 | ||
40 | let mut to_download: Vec<String> = vec![]; | 47 | let mut to_download: Vec<String> = vec![]; |
41 | //(mod_id, version_id) | 48 | //(mod_id, version_id) |
@@ -54,7 +61,10 @@ pub async fn download( | |||
54 | .ok_or("SOMETHING_HAS_REALLY_GONE_WRONG") | 61 | .ok_or("SOMETHING_HAS_REALLY_GONE_WRONG") |
55 | .unwrap(); | 62 | .unwrap(); |
56 | if ¤t_version != downloaded_version { | 63 | if ¤t_version != downloaded_version { |
57 | to_disable.push((mod_id.clone(), String::from(downloaded_version))); | 64 | to_disable.push(( |
65 | mod_id.clone(), | ||
66 | String::from(downloaded_version), | ||
67 | )); | ||
58 | to_download.push(current_version); | 68 | to_download.push(current_version); |
59 | } | 69 | } |
60 | } | 70 | } |
@@ -98,7 +108,12 @@ pub async fn download( | |||
98 | } else { | 108 | } else { |
99 | d_p.set_message(format!("Disable version {}", ver.1)); | 109 | d_p.set_message(format!("Disable version {}", ver.1)); |
100 | d_p.inc(1); | 110 | d_p.inc(1); |
101 | disable_version(config, current_list.clone(), ver.1, ver.0)?; | 111 | disable_version( |
112 | config, | ||
113 | current_list.clone(), | ||
114 | ver.1, | ||
115 | ver.0, | ||
116 | )?; | ||
102 | }; | 117 | }; |
103 | } | 118 | } |
104 | 119 | ||