From 54752f7eb39e20929a7816c90be33bf8dbff2a6c Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Sun, 29 Jan 2023 13:56:06 +0100 Subject: fixed not downloading on mod add --- src/commands/modification.rs | 4 ++-- src/commands/update.rs | 3 +-- src/files.rs | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/commands/modification.rs b/src/commands/modification.rs index c194202..c82d6b5 100644 --- a/src/commands/modification.rs +++ b/src/commands/modification.rs @@ -18,7 +18,7 @@ async fn add(config: Cfg, input: Input) -> MLE<()> { Ok(()) } -pub async fn mod_add(config: Cfg, mod_id: Vec, list: List, disable_download: bool) -> MLE<()> { +pub async fn mod_add(config: Cfg, mod_id: Vec, list: List, direct_download: bool) -> MLE<()> { //Fix printing (its horrible) println!("Adding mod(s) {:?}", mod_id); @@ -80,7 +80,7 @@ pub async fn mod_add(config: Cfg, mod_id: Vec, list: List, disable_downl }, }; - if !disable_download && current_version.is_some() { download_versions(list.clone(), config.clone(), vec![current_version.unwrap()]).await?; }; + if direct_download && current_version.is_some() { download_versions(list.clone(), config.clone(), vec![current_version.unwrap()]).await?; }; } diff --git a/src/commands/update.rs b/src/commands/update.rs index f71f537..d400a24 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -74,7 +74,7 @@ pub async fn cmd_update(config: Cfg, liststack: Vec, clean: bool, direct_d //Linebreak readability println!(""); - if direct_download { + if direct_download && !updatestack.is_empty() { download_versions(current_list.clone(), config.clone(), updatestack).await?; //Disable old versions @@ -90,7 +90,6 @@ pub async fn cmd_update(config: Cfg, liststack: Vec, clean: bool, direct_d } } }; - } Ok(()) diff --git a/src/files.rs b/src/files.rs index ecb6e3e..8c822b2 100644 --- a/src/files.rs +++ b/src/files.rs @@ -13,6 +13,7 @@ pub async fn download_versions(list: List, config: Cfg, versions: Vec) for ver in versions { let project_name = mods_get_name(config.clone(), &ver.project_id)?; print!("\t({})Download version {}", project_name, ver.id); + //Force flush of stdout, else print! doesn't print instantly std::io::stdout().flush().unwrap(); let primary_file = ver.files.into_iter().find(|file| file.primary).unwrap(); let mut splitname: Vec<&str> = primary_file.filename.split('.').collect(); @@ -22,7 +23,7 @@ pub async fn download_versions(list: List, config: Cfg, versions: Vec) }; let filename = format!("{}.mr.{}.{}.{}", splitname.join("."), ver.project_id, ver.id, extension); download_file(primary_file.url, list.clone().download_folder, filename).await?; - tokio::time::sleep(std::time::Duration::new(3, 0)).await; + //tokio::time::sleep(std::time::Duration::new(3, 0)).await; println!(" ✓"); } -- cgit v1.2.3