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.rs30
1 files changed, 17 insertions, 13 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 )?;