summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/download.rs30
-rw-r--r--src/commands/io.rs24
-rw-r--r--src/commands/list.rs33
-rw-r--r--src/commands/modification.rs57
-rw-r--r--src/commands/update.rs39
5 files changed, 116 insertions, 67 deletions
diff --git a/src/commands/download.rs b/src/commands/download.rs
index 3e50c87..7321832 100644
--- a/src/commands/download.rs
+++ b/src/commands/download.rs
@@ -1,9 +1,11 @@
1#![allow(clippy::too_many_lines)]
2
1use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; 3use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
2 4
3use crate::{config::Cfg, List}; 5use crate::{config::Cfg, List};
4use crate::{ 6use crate::{
5 db::userlist_get_all_current_versions_with_mods, 7 db::userlist_get_all_current_versions_with_mods,
6 error::{ErrorType, MLError, MLE}, 8 error::{EType, MLErr, MLE},
7 files::{ 9 files::{
8 clean_list_dir, delete_version, disable_version, download_versions, 10 clean_list_dir, delete_version, disable_version, download_versions,
9 get_downloaded_versions, 11 get_downloaded_versions,
@@ -12,6 +14,8 @@ use crate::{
12}; 14};
13use crate::{PROGRESS_CHARS, STYLE_BAR_POS}; 15use crate::{PROGRESS_CHARS, STYLE_BAR_POS};
14 16
17/// # Errors
18/// # Panics
15pub async fn download( 19pub async fn download(
16 config: &Cfg, 20 config: &Cfg,
17 liststack: Vec<List>, 21 liststack: Vec<List>,
@@ -31,15 +35,15 @@ pub async fn download(
31 download_p.set_message(format!("Download in {}", current_list.id)); 35 download_p.set_message(format!("Download in {}", current_list.id));
32 36
33 let downloaded_versions = 37 let downloaded_versions =
34 get_downloaded_versions(current_list.clone())?; 38 get_downloaded_versions(&current_list)?;
35 let current_version_ids = 39 let current_version_ids =
36 match userlist_get_all_current_versions_with_mods( 40 match userlist_get_all_current_versions_with_mods(
37 config, 41 config,
38 String::from(&current_list.id), 42 &current_list.id,
39 ) { 43 ) {
40 Ok(i) => Ok(i), 44 Ok(i) => Ok(i),
41 Err(e) => Err(MLError::new( 45 Err(e) => Err(MLErr::new(
42 ErrorType::DBError, 46 EType::DBError,
43 e.to_string().as_str(), 47 e.to_string().as_str(),
44 )), 48 )),
45 }?; 49 }?;
@@ -74,7 +78,12 @@ pub async fn download(
74 clean_list_dir(&current_list)?; 78 clean_list_dir(&current_list)?;
75 }; 79 };
76 80
77 if !to_download.is_empty() { 81 if to_download.is_empty() {
82 download_p.println(format!(
83 "There are no new versions to download for {}",
84 current_list.id
85 ));
86 } else {
78 download_versions( 87 download_versions(
79 current_list.clone(), 88 current_list.clone(),
80 config.clone(), 89 config.clone(),
@@ -83,11 +92,6 @@ pub async fn download(
83 &download_p, 92 &download_p,
84 ) 93 )
85 .await?; 94 .await?;
86 } else {
87 download_p.println(format!(
88 "There are no new versions to download for {}",
89 current_list.id
90 ));
91 } 95 }
92 96
93 if !to_disable.is_empty() { 97 if !to_disable.is_empty() {
@@ -104,13 +108,13 @@ pub async fn download(
104 if delete_old { 108 if delete_old {
105 d_p.set_message(format!("Delete version {}", ver.1)); 109 d_p.set_message(format!("Delete version {}", ver.1));
106 d_p.inc(1); 110 d_p.inc(1);
107 delete_version(&current_list, ver.1)?; 111 delete_version(&current_list, &ver.1)?;
108 } else { 112 } else {
109 d_p.set_message(format!("Disable version {}", ver.1)); 113 d_p.set_message(format!("Disable version {}", ver.1));
110 d_p.inc(1); 114 d_p.inc(1);
111 disable_version( 115 disable_version(
112 config, 116 config,
113 current_list.clone(), 117 &current_list,
114 ver.1, 118 ver.1,
115 ver.0, 119 ver.0,
116 )?; 120 )?;
diff --git a/src/commands/io.rs b/src/commands/io.rs
index 1d17f7c..c9691c4 100644
--- a/src/commands/io.rs
+++ b/src/commands/io.rs
@@ -9,7 +9,7 @@ use crate::{
9 lists_get, lists_get_all_ids, lists_insert, userlist_get_all_ids, 9 lists_get, lists_get_all_ids, lists_insert, userlist_get_all_ids,
10 userlist_get_current_version, userlist_get_set_version, 10 userlist_get_current_version, userlist_get_set_version,
11 }, 11 },
12 error::MLE, 12 error::{EType, MLErr, MLE},
13 mod_add, AddMod, IDSelector, List, Modloader, STYLE_OPERATION, 13 mod_add, AddMod, IDSelector, List, Modloader, STYLE_OPERATION,
14}; 14};
15 15
@@ -67,15 +67,26 @@ impl ExportList {
67 } 67 }
68} 68}
69 69
70/// # Errors
71/// # Panics
70pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> { 72pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> {
71 let progress = ProgressBar::new_spinner(); 73 let progress = ProgressBar::new_spinner();
72 progress.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 74 progress.set_style(
75 ProgressStyle::with_template(STYLE_OPERATION)
76 .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))?,
77 );
73 78
74 let mut list_ids: Vec<String> = vec![]; 79 let mut list_ids: Vec<String> = vec![];
75 if list.is_none() { 80 if list.is_none() {
76 list_ids = lists_get_all_ids(config)?; 81 list_ids = lists_get_all_ids(config)?;
77 } else { 82 } else {
78 list_ids.push(lists_get(config, &list.unwrap())?.id); 83 list_ids.push(
84 lists_get(
85 config,
86 &list.ok_or(MLErr::new(EType::Other, "nolist"))?,
87 )?
88 .id,
89 );
79 } 90 }
80 91
81 let mut lists: Vec<ExportList> = vec![]; 92 let mut lists: Vec<ExportList> = vec![];
@@ -88,7 +99,7 @@ pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> {
88 let toml = toml::to_string(&Export { lists })?; 99 let toml = toml::to_string(&Export { lists })?;
89 100
90 let filestr = dirs::home_dir() 101 let filestr = dirs::home_dir()
91 .unwrap() 102 .ok_or(MLErr::new(EType::Other, "no home"))?
92 .join("mlexport.toml") 103 .join("mlexport.toml")
93 .into_os_string() 104 .into_os_string()
94 .into_string() 105 .into_string()
@@ -102,6 +113,7 @@ pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> {
102 Ok(()) 113 Ok(())
103} 114}
104 115
116/// # Errors
105pub async fn import( 117pub async fn import(
106 config: &Cfg, 118 config: &Cfg,
107 file_str: &str, 119 file_str: &str,
@@ -117,7 +129,9 @@ pub async fn import(
117 id: exportlist.id, 129 id: exportlist.id,
118 mc_version: exportlist.mc_version, 130 mc_version: exportlist.mc_version,
119 modloader: Modloader::from(&exportlist.launcher)?, 131 modloader: Modloader::from(&exportlist.launcher)?,
120 download_folder: exportlist.download_folder.ok_or("NO_DL").unwrap(), 132 download_folder: exportlist
133 .download_folder
134 .ok_or(MLErr::new(EType::Other, "NO_DL"))?,
121 }; 135 };
122 lists_insert( 136 lists_insert(
123 config, 137 config,
diff --git a/src/commands/list.rs b/src/commands/list.rs
index 63105cf..47c1dc6 100644
--- a/src/commands/list.rs
+++ b/src/commands/list.rs
@@ -1,3 +1,4 @@
1#![allow(clippy::module_name_repetitions)]
1use indicatif::{ProgressBar, ProgressStyle}; 2use indicatif::{ProgressBar, ProgressStyle};
2 3
3use crate::{ 4use crate::{
@@ -6,7 +7,7 @@ use crate::{
6 config_change_current_list, config_get_current_list, lists_get, 7 config_change_current_list, config_get_current_list, lists_get,
7 lists_get_all_ids, lists_insert, lists_remove, lists_version, 8 lists_get_all_ids, lists_insert, lists_remove, lists_version,
8 }, 9 },
9 error::{ErrorType, MLError, MLE}, 10 error::{EType, MLErr, MLE},
10 update, Modloader, STYLE_OPERATION, 11 update, Modloader, STYLE_OPERATION,
11}; 12};
12 13
@@ -18,11 +19,13 @@ pub struct List {
18 pub download_folder: String, 19 pub download_folder: String,
19} 20}
20 21
22/// # Errors
21pub fn get_current_list(config: &Cfg) -> MLE<List> { 23pub fn get_current_list(config: &Cfg) -> MLE<List> {
22 let id = config_get_current_list(config)?; 24 let id = config_get_current_list(config)?;
23 lists_get(config, &id) 25 lists_get(config, &id)
24} 26}
25 27
28/// # Errors
26pub fn list_add( 29pub fn list_add(
27 config: &Cfg, 30 config: &Cfg,
28 id: &str, 31 id: &str,
@@ -31,20 +34,27 @@ pub fn list_add(
31 directory: &str, 34 directory: &str,
32) -> MLE<()> { 35) -> MLE<()> {
33 let p = ProgressBar::new_spinner(); 36 let p = ProgressBar::new_spinner();
34 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 37 p.set_style(
38 ProgressStyle::with_template(STYLE_OPERATION)
39 .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))?,
40 );
35 p.set_message(format!("Create {id}")); 41 p.set_message(format!("Create {id}"));
36 lists_insert(config, id, mc_version, modloader, directory)?; 42 lists_insert(config, id, mc_version, modloader, directory)?;
37 p.finish_with_message(format!("Created {id}")); 43 p.finish_with_message(format!("Created {id}"));
38 Ok(()) 44 Ok(())
39} 45}
40 46
47/// # Errors
41pub fn list_change(config: &Cfg, id: &str) -> MLE<()> { 48pub fn list_change(config: &Cfg, id: &str) -> MLE<()> {
42 let p = ProgressBar::new_spinner(); 49 let p = ProgressBar::new_spinner();
43 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 50 p.set_style(
51 ProgressStyle::with_template(STYLE_OPERATION)
52 .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))?,
53 );
44 p.set_message(format!("Change default list to {id}")); 54 p.set_message(format!("Change default list to {id}"));
45 55
46 if !lists_get_all_ids(config)?.into_iter().any(|l| l == id) { 56 if !lists_get_all_ids(config)?.into_iter().any(|l| l == id) {
47 return Err(MLError::new(ErrorType::ArgumentError, "List not found")); 57 return Err(MLErr::new(EType::ArgumentError, "List not found"));
48 }; 58 };
49 config_change_current_list(config, id)?; 59 config_change_current_list(config, id)?;
50 60
@@ -52,9 +62,13 @@ pub fn list_change(config: &Cfg, id: &str) -> MLE<()> {
52 Ok(()) 62 Ok(())
53} 63}
54 64
65/// # Errors
55pub fn list_remove(config: &Cfg, id: &str) -> MLE<()> { 66pub fn list_remove(config: &Cfg, id: &str) -> MLE<()> {
56 let p = ProgressBar::new_spinner(); 67 let p = ProgressBar::new_spinner();
57 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 68 p.set_style(
69 ProgressStyle::with_template(STYLE_OPERATION)
70 .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))?,
71 );
58 p.set_message(format!("Remove {id}")); 72 p.set_message(format!("Remove {id}"));
59 lists_remove(config, id)?; 73 lists_remove(config, id)?;
60 p.finish_with_message(format!("Removed {id}")); 74 p.finish_with_message(format!("Removed {id}"));
@@ -67,6 +81,7 @@ pub fn list_remove(config: &Cfg, id: &str) -> MLE<()> {
67/// 81///
68/// * `config` - The current config 82/// * `config` - The current config
69/// * `args` - All args, to extract the new version 83/// * `args` - All args, to extract the new version
84/// # Errors
70pub async fn list_version( 85pub async fn list_version(
71 config: &Cfg, 86 config: &Cfg,
72 id: &str, 87 id: &str,
@@ -75,7 +90,10 @@ pub async fn list_version(
75 delete: bool, 90 delete: bool,
76) -> MLE<()> { 91) -> MLE<()> {
77 let p = ProgressBar::new_spinner(); 92 let p = ProgressBar::new_spinner();
78 p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 93 p.set_style(
94 ProgressStyle::with_template(STYLE_OPERATION)
95 .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))?,
96 );
79 p.set_message(format!( 97 p.set_message(format!(
80 "Change version for list {id} to minecraft version: {mc_version}" 98 "Change version for list {id} to minecraft version: {mc_version}"
81 )); 99 ));
@@ -90,7 +108,8 @@ pub async fn list_version(
90 update(config, vec![list], true, download, delete).await 108 update(config, vec![list], true, download, delete).await
91} 109}
92 110
93pub fn list_list(config: &Cfg) -> MLE<()> { 111/// # Errors
112pub fn list_lists(config: &Cfg) -> MLE<()> {
94 let lists = lists_get_all_ids(config)?; 113 let lists = lists_get_all_ids(config)?;
95 for list in lists { 114 for list in lists {
96 let l = lists_get(config, &list)?; 115 let l = lists_get(config, &list)?;
diff --git a/src/commands/modification.rs b/src/commands/modification.rs
index e0e54b2..6e6213f 100644
--- a/src/commands/modification.rs
+++ b/src/commands/modification.rs
@@ -1,3 +1,5 @@
1#![allow(clippy::too_many_lines)]
2
1use std::collections::HashMap; 3use std::collections::HashMap;
2 4
3use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; 5use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
@@ -9,7 +11,7 @@ use crate::{
9 mods_remove, userlist_get_all_ids, userlist_get_current_version, 11 mods_remove, userlist_get_all_ids, userlist_get_current_version,
10 userlist_insert, userlist_remove, 12 userlist_insert, userlist_remove,
11 }, 13 },
12 error::{ErrorType, MLError, MLE}, 14 error::{EType, MLErr, MLE},
13 files::{delete_version, download_versions}, 15 files::{delete_version, download_versions},
14 modrinth::{ 16 modrinth::{
15 extract_current_version, get_raw_versions, project, projects, versions, 17 extract_current_version, get_raw_versions, project, projects, versions,
@@ -41,6 +43,8 @@ pub struct ProjectInfo {
41 pub set_version: bool, 43 pub set_version: bool,
42} 44}
43 45
46/// # Errors
47/// # Panics
44pub async fn mod_add( 48pub async fn mod_add(
45 config: &Cfg, 49 config: &Cfg,
46 mods: Vec<AddMod>, 50 mods: Vec<AddMod>,
@@ -52,10 +56,11 @@ pub async fn mod_add(
52 let mut mod_ids: Vec<(String, bool)> = Vec::new(); 56 let mut mod_ids: Vec<(String, bool)> = Vec::new();
53 let mut ver_ids: Vec<(String, bool)> = Vec::new(); 57 let mut ver_ids: Vec<(String, bool)> = Vec::new();
54 58
55 let add_p = mp.add(ProgressBar::new(mods.len().try_into().unwrap())); 59 let add_p = mp.add(ProgressBar::new(mods.len().try_into().map_err(|_| MLErr::new(EType::Other, "MODSLENTRY"))?));
56 add_p.set_style( 60 add_p.set_style(
57 ProgressStyle::with_template(STYLE_BAR_POS) 61 ProgressStyle::with_template(STYLE_BAR_POS).map_err(|_| {
58 .unwrap() 62 MLErr::new(EType::LibIndicatif, "template error")
63 })?
59 .progress_chars(PROGRESS_CHARS), 64 .progress_chars(PROGRESS_CHARS),
60 ); 65 );
61 add_p.set_message("Sort ids"); 66 add_p.set_message("Sort ids");
@@ -83,7 +88,7 @@ pub async fn mod_add(
83 }; 88 };
84 89
85 if projectinfo.is_empty() { 90 if projectinfo.is_empty() {
86 return Err(MLError::new(ErrorType::ArgumentError, "NO_IDS?")); 91 return Err(MLErr::new(EType::ArgumentError, "NO_IDS?"));
87 }; 92 };
88 93
89 add_p.set_message("Add mods to database"); 94 add_p.set_message("Add mods to database");
@@ -115,7 +120,7 @@ pub async fn mod_add(
115 &list.id, 120 &list.id,
116 &project.mod_id, 121 &project.mod_id,
117 &current_version_id, 122 &current_version_id,
118 project.clone().applicable_versions, 123 &project.applicable_versions,
119 &project.download_link, 124 &project.download_link,
120 project.set_version, 125 project.set_version,
121 ) { 126 ) {
@@ -125,8 +130,8 @@ pub async fn mod_add(
125 list.id 130 list.id
126 ); 131 );
127 if e.to_string() == expected_err { 132 if e.to_string() == expected_err {
128 Err(MLError::new( 133 Err(MLErr::new(
129 ErrorType::ModError, 134 EType::ModError,
130 "MOD_ALREADY_ON_SELECTED_LIST", 135 "MOD_ALREADY_ON_SELECTED_LIST",
131 )) 136 ))
132 } else { 137 } else {
@@ -212,7 +217,20 @@ async fn get_mod_infos(
212 let mut available_versions_vec: Vec<String> = Vec::new(); 217 let mut available_versions_vec: Vec<String> = Vec::new();
213 let current_version: Option<Version>; 218 let current_version: Option<Version>;
214 let file: String; 219 let file: String;
215 if !available_versions.is_empty() { 220 if available_versions.is_empty() {
221 current_version = None;
222 file = String::from("NONE");
223 available_versions_vec.push(String::from("NONE"));
224 projectinfo.push(ProjectInfo {
225 mod_id: String::from(&project.id),
226 slug: project.slug,
227 title: project.title,
228 current_version,
229 applicable_versions: available_versions_vec,
230 download_link: file,
231 set_version: *setmap.get(&project.id).unwrap(),
232 });
233 } else {
216 let current_id = 234 let current_id =
217 extract_current_version(available_versions.clone())?; 235 extract_current_version(available_versions.clone())?;
218 236
@@ -246,19 +264,6 @@ async fn get_mod_infos(
246 download_link: file, 264 download_link: file,
247 set_version: *setmap.get(&project.slug).unwrap(), 265 set_version: *setmap.get(&project.slug).unwrap(),
248 }); 266 });
249 } else {
250 current_version = None;
251 file = String::from("NONE");
252 available_versions_vec.push(String::from("NONE"));
253 projectinfo.push(ProjectInfo {
254 mod_id: String::from(&project.id),
255 slug: project.slug,
256 title: project.title,
257 current_version,
258 applicable_versions: available_versions_vec,
259 download_link: file,
260 set_version: *setmap.get(&project.id).unwrap(),
261 });
262 } 267 }
263 } 268 }
264 269
@@ -319,9 +324,13 @@ async fn get_ver_info(
319/// * `config` - config struct 324/// * `config` - config struct
320/// * `id` - name, slug or id of the mod 325/// * `id` - name, slug or id of the mod
321/// * `list` - List struct 326/// * `list` - List struct
327///
328/// # Errors
322pub fn mod_remove(config: &Cfg, id: &str, list: &List) -> MLE<()> { 329pub fn mod_remove(config: &Cfg, id: &str, list: &List) -> MLE<()> {
323 let progress = ProgressBar::new_spinner(); 330 let progress = ProgressBar::new_spinner();
324 progress.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); 331 progress.set_style(ProgressStyle::with_template(STYLE_OPERATION).map_err(|_| {
332 MLErr::new(EType::LibIndicatif, "template error")
333 })?);
325 334
326 let mod_id = mods_get_id(&config.data, id)?; 335 let mod_id = mods_get_id(&config.data, id)?;
327 336
@@ -334,7 +343,7 @@ pub fn mod_remove(config: &Cfg, id: &str, list: &List) -> MLE<()> {
334 userlist_remove(config, &list.id, &mod_id)?; 343 userlist_remove(config, &list.id, &mod_id)?;
335 344
336 progress.set_message("Delete file"); 345 progress.set_message("Delete file");
337 match delete_version(list, version) { 346 match delete_version(list, &version) {
338 Ok(()) => (), 347 Ok(()) => (),
339 Err(err) => { 348 Err(err) => {
340 if err.to_string() 349 if err.to_string()
diff --git a/src/commands/update.rs b/src/commands/update.rs
index c19c02c..d0b930d 100644
--- a/src/commands/update.rs
+++ b/src/commands/update.rs
@@ -1,3 +1,5 @@
1#![allow(clippy::too_many_lines)]
2
1use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; 3use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
2 4
3use crate::{ 5use crate::{
@@ -7,7 +9,7 @@ use crate::{
7 userlist_get_applicable_versions, userlist_get_current_version, 9 userlist_get_applicable_versions, userlist_get_current_version,
8 userlist_get_set_version, 10 userlist_get_set_version,
9 }, 11 },
10 error::{ErrorType, MLError, MLE}, 12 error::{EType, MLErr, MLE},
11 files::{ 13 files::{
12 clean_list_dir, delete_version, disable_version, download_versions, 14 clean_list_dir, delete_version, disable_version, download_versions,
13 }, 15 },
@@ -15,6 +17,8 @@ use crate::{
15 List, PROGRESS_CHARS, STYLE_BAR_POS, STYLE_OPERATION, 17 List, PROGRESS_CHARS, STYLE_BAR_POS, STYLE_OPERATION,
16}; 18};
17 19
20/// # Errors
21/// # Panics
18pub async fn update( 22pub async fn update(
19 config: &Cfg, 23 config: &Cfg,
20 liststack: Vec<List>, 24 liststack: Vec<List>,
@@ -24,11 +28,15 @@ pub async fn update(
24) -> MLE<()> { 28) -> MLE<()> {
25 let mp = MultiProgress::new(); 29 let mp = MultiProgress::new();
26 30
27 let update_p = 31 let update_p = mp.add(ProgressBar::new(
28 mp.add(ProgressBar::new(liststack.len().try_into().unwrap())); 32 liststack
33 .len()
34 .try_into()
35 .map_err(|_| MLErr::new(EType::Other, "ListStackLen"))?,
36 ));
29 update_p.set_style( 37 update_p.set_style(
30 ProgressStyle::with_template(STYLE_BAR_POS) 38 ProgressStyle::with_template(STYLE_BAR_POS)
31 .unwrap() 39 .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))?
32 .progress_chars(PROGRESS_CHARS), 40 .progress_chars(PROGRESS_CHARS),
33 ); 41 );
34 42
@@ -133,16 +141,11 @@ pub async fn update(
133 if delete_old { 141 if delete_old {
134 d_p.set_message(format!("Delete version {}", ver.0)); 142 d_p.set_message(format!("Delete version {}", ver.0));
135 d_p.inc(1); 143 d_p.inc(1);
136 delete_version(&current_list, ver.0)?; 144 delete_version(&current_list, &ver.0)?;
137 } else if ver.0 != "NONE" { 145 } else if ver.0 != "NONE" {
138 d_p.set_message(format!("Disable version {}", ver.0)); 146 d_p.set_message(format!("Disable version {}", ver.0));
139 d_p.inc(1); 147 d_p.inc(1);
140 disable_version( 148 disable_version(config, &current_list, ver.0, ver.1)?;
141 config,
142 current_list.clone(),
143 ver.0,
144 ver.1,
145 )?;
146 }; 149 };
147 } 150 }
148 151
@@ -176,12 +179,12 @@ async fn specific_update(
176 179
177 let mut versions: Vec<String> = vec![]; 180 let mut versions: Vec<String> = vec![];
178 181
179 if !applicable_versions.is_empty() { 182 if applicable_versions.is_empty() {
183 versions.push(String::from("NONE"));
184 } else {
180 for ver in &applicable_versions { 185 for ver in &applicable_versions {
181 versions.push(String::from(&ver.id)); 186 versions.push(String::from(&ver.id));
182 } 187 }
183 } else {
184 versions.push(String::from("NONE"));
185 } 188 }
186 189
187 let mut current: Vec<Version> = vec![]; 190 let mut current: Vec<Version> = vec![];
@@ -189,7 +192,7 @@ async fn specific_update(
189 || (versions.join("|") 192 || (versions.join("|")
190 != userlist_get_applicable_versions( 193 != userlist_get_applicable_versions(
191 config, 194 config,
192 String::from(&list.id), 195 &list.id,
193 String::from(id), 196 String::from(id),
194 )?) 197 )?)
195 { 198 {
@@ -209,7 +212,7 @@ async fn specific_update(
209 .ok_or("!no current version in applicable_versions") 212 .ok_or("!no current version in applicable_versions")
210 { 213 {
211 Ok(v) => Ok(v), 214 Ok(v) => Ok(v),
212 Err(e) => Err(MLError::new(ErrorType::Other, e)), 215 Err(e) => Err(MLErr::new(EType::Other, e)),
213 }?; 216 }?;
214 current.push(current_ver.clone()); 217 current.push(current_ver.clone());
215 218
@@ -223,7 +226,7 @@ async fn specific_update(
223 226
224 userlist_change_versions( 227 userlist_change_versions(
225 config, 228 config,
226 list.id, 229 &list.id,
227 current_str, 230 current_str,
228 versions.join("|"), 231 versions.join("|"),
229 link, 232 link,
@@ -232,7 +235,7 @@ async fn specific_update(
232 } 235 }
233 236
234 if current.is_empty() { 237 if current.is_empty() {
235 return Err(MLError::new(ErrorType::ModError, "NO_UPDATE_AVAILABLE")); 238 return Err(MLErr::new(EType::ModError, "NO_UPDATE_AVAILABLE"));
236 }; 239 };
237 240
238 Ok(current[0].clone()) 241 Ok(current[0].clone())