summaryrefslogtreecommitdiff
path: root/src/commands/download.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/download.rs')
-rw-r--r--src/commands/download.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/commands/download.rs b/src/commands/download.rs
index b958bf3..0f63876 100644
--- a/src/commands/download.rs
+++ b/src/commands/download.rs
@@ -1,7 +1,7 @@
1use crate::{files::{get_downloaded_versions, download_versions, delete_version, disable_version}, db::{userlist_get_all_current_versions_with_mods, lists_get_all_ids, lists_get}, modrinth::get_raw_versions}; 1use crate::{files::{get_downloaded_versions, download_versions, delete_version, disable_version}, db::{userlist_get_all_current_versions_with_mods, lists_get_all_ids, lists_get}, modrinth::get_raw_versions, error::{MLE, ErrorType, MLError}};
2use crate::{List, get_current_list, config::Cfg, input::Input}; 2use crate::{List, get_current_list, config::Cfg, input::Input};
3 3
4pub async fn download(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> { 4pub async fn download(config: Cfg, input: Input) -> MLE<()> {
5 5
6 let mut liststack: Vec<List> = vec![]; 6 let mut liststack: Vec<List> = vec![];
7 if input.all_lists { 7 if input.all_lists {
@@ -18,7 +18,10 @@ pub async fn download(config: Cfg, input: Input) -> Result<(), Box<dyn std::erro
18 for current_list in liststack { 18 for current_list in liststack {
19 let downloaded_versions = get_downloaded_versions(current_list.clone())?; 19 let downloaded_versions = get_downloaded_versions(current_list.clone())?;
20 println!("To download: {:#?}", downloaded_versions); 20 println!("To download: {:#?}", downloaded_versions);
21 let current_version_ids = userlist_get_all_current_versions_with_mods(config.clone(), String::from(&current_list.id))?; 21 let current_version_ids = match userlist_get_all_current_versions_with_mods(config.clone(), String::from(&current_list.id)) {
22 Ok(i) => Ok(i),
23 Err(e) => Err(MLError::new(ErrorType::DBError, e.to_string().as_str())),
24 }?;
22 25
23 let mut to_download: Vec<String> = vec![]; 26 let mut to_download: Vec<String> = vec![];
24 //(mod_id, version_id) 27 //(mod_id, version_id)
@@ -33,7 +36,7 @@ pub async fn download(config: Cfg, input: Input) -> Result<(), Box<dyn std::erro
33 if current_download.is_none() || input.clean { 36 if current_download.is_none() || input.clean {
34 to_download.push(current_version); 37 to_download.push(current_version);
35 } else { 38 } else {
36 let downloaded_version = current_download.ok_or("SOMETHING_HAS_REALLY_GONE_WRONG")?; 39 let downloaded_version = current_download.ok_or("SOMETHING_HAS_REALLY_GONE_WRONG").unwrap();
37 if &current_version != downloaded_version { 40 if &current_version != downloaded_version {
38 to_disable.push((mod_id.clone(), String::from(downloaded_version))); 41 to_disable.push((mod_id.clone(), String::from(downloaded_version)));
39 to_download.push(current_version); 42 to_download.push(current_version);