diff options
Diffstat (limited to 'src/commands/update.rs')
-rw-r--r-- | src/commands/update.rs | 84 |
1 files changed, 44 insertions, 40 deletions
diff --git a/src/commands/update.rs b/src/commands/update.rs index c7965e3..f83030d 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs | |||
@@ -1,5 +1,3 @@ | |||
1 | #![allow(clippy::too_many_lines)] | ||
2 | |||
3 | use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; | 1 | use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; |
4 | 2 | ||
5 | use crate::{ | 3 | use crate::{ |
@@ -70,44 +68,7 @@ pub async fn update( | |||
70 | let mut updatestack: Vec<Version> = vec![]; | 68 | let mut updatestack: Vec<Version> = vec![]; |
71 | 69 | ||
72 | for id in mods { | 70 | for id in mods { |
73 | let info = mods_get_info(config, &id)?; | 71 | update_mod(config, id, list_u_p.clone(), ¤t_list, &mut updatestack, &mut current_versions, clean).await?; |
74 | list_u_p.set_message(format!("Update {}", info.title)); | ||
75 | |||
76 | //Skip check if version is set | ||
77 | if userlist_get_set_version(config, ¤t_list.id, &id)? { | ||
78 | list_u_p.inc(1); | ||
79 | continue; | ||
80 | } | ||
81 | |||
82 | //Getting current installed version for disable or delete | ||
83 | let disable_version = | ||
84 | userlist_get_current_version(config, ¤t_list.id, &id)?; | ||
85 | |||
86 | updatestack.push( | ||
87 | match specific_update( | ||
88 | config, | ||
89 | clean, | ||
90 | current_list.clone(), | ||
91 | &id, | ||
92 | &list_u_p, | ||
93 | ) | ||
94 | .await | ||
95 | { | ||
96 | Ok(ver) => { | ||
97 | current_versions.push((disable_version, id)); | ||
98 | ver | ||
99 | } | ||
100 | Err(e) => { | ||
101 | if e.to_string() == "Mod: NO_UPDATE_AVAILABLE" { | ||
102 | } else { | ||
103 | return Err(e); | ||
104 | }; | ||
105 | list_u_p.inc(1); | ||
106 | continue; | ||
107 | } | ||
108 | }, | ||
109 | ); | ||
110 | list_u_p.inc(1); | ||
111 | } | 72 | } |
112 | 73 | ||
113 | list_u_p.finish_with_message(format!( | 74 | list_u_p.finish_with_message(format!( |
@@ -173,6 +134,49 @@ pub async fn update( | |||
173 | Ok(()) | 134 | Ok(()) |
174 | } | 135 | } |
175 | 136 | ||
137 | async fn update_mod(config: &Cfg, id: String, list_u_p: ProgressBar, current_list: &List, updatestack: &mut Vec<Version>, current_versions: &mut Vec<(String, String)>, clean: bool) -> MLE<()> { | ||
138 | let info = mods_get_info(config, &id)?; | ||
139 | list_u_p.set_message(format!("Update {}", info.title)); | ||
140 | |||
141 | //Skip check if version is set | ||
142 | if userlist_get_set_version(config, ¤t_list.id, &id)? { | ||
143 | list_u_p.inc(1); | ||
144 | return Ok(()); | ||
145 | } | ||
146 | |||
147 | //Getting current installed version for disable or delete | ||
148 | let disable_version = | ||
149 | userlist_get_current_version(config, ¤t_list.id, &id)?; | ||
150 | |||
151 | updatestack.push( | ||
152 | match specific_update( | ||
153 | config, | ||
154 | clean, | ||
155 | current_list.clone(), | ||
156 | &id, | ||
157 | &list_u_p, | ||
158 | ) | ||
159 | .await | ||
160 | { | ||
161 | Ok(ver) => { | ||
162 | current_versions.push((disable_version, id.to_string())); | ||
163 | ver | ||
164 | } | ||
165 | Err(e) => { | ||
166 | if e.to_string() == "Mod: NO_UPDATE_AVAILABLE" { | ||
167 | } else { | ||
168 | return Err(e); | ||
169 | }; | ||
170 | list_u_p.inc(1); | ||
171 | return Ok(()); | ||
172 | } | ||
173 | }, | ||
174 | ); | ||
175 | list_u_p.inc(1); | ||
176 | |||
177 | Ok(()) | ||
178 | } | ||
179 | |||
176 | async fn specific_update( | 180 | async fn specific_update( |
177 | config: &Cfg, | 181 | config: &Cfg, |
178 | clean: bool, | 182 | clean: bool, |