From 1890d59428dfcca861ea1b7820411d80cc60d713 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Sun, 22 Jan 2023 22:34:17 +0100 Subject: Added list version cmd, fixed some todos --- src/commands/download.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/commands/download.rs') diff --git a/src/commands/download.rs b/src/commands/download.rs index 0f63876..7748d15 100644 --- a/src/commands/download.rs +++ b/src/commands/download.rs @@ -1,4 +1,4 @@ -use 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}}; +use crate::{files::{get_downloaded_versions, download_versions, delete_version, disable_version, clean_list_dir}, db::{userlist_get_all_current_versions_with_mods, lists_get_all_ids, lists_get}, modrinth::get_raw_versions, error::{MLE, ErrorType, MLError}}; use crate::{List, get_current_list, config::Cfg, input::Input}; pub async fn download(config: Cfg, input: Input) -> MLE<()> { @@ -44,17 +44,10 @@ pub async fn download(config: Cfg, input: Input) -> MLE<()> { } } - if input.clean { - let dl_path = ¤t_list.download_folder; - println!("Cleaning {}", dl_path); - for entry in std::fs::read_dir(dl_path)? { - let entry = entry?; - std::fs::remove_file(entry.path())?; - } - } + if input.clean { clean_list_dir(¤t_list)? }; if !to_download.is_empty() { - download_versions(current_list.clone(), get_raw_versions(String::from(&config.apis.modrinth), to_download).await).await?; + download_versions(current_list.clone(), config.clone(), get_raw_versions(String::from(&config.apis.modrinth), to_download).await).await?; } else { println!("There are no new versions to download"); } -- cgit v1.2.3