From 758e608e6c331df2a5900de7f932f9b498573ed1 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Wed, 7 Dec 2022 17:45:16 +0100 Subject: groundwork for downloads; cleanup --- src/commands/download.rs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src/commands/download.rs') diff --git a/src/commands/download.rs b/src/commands/download.rs index b0efdc2..421f058 100644 --- a/src/commands/download.rs +++ b/src/commands/download.rs @@ -1,9 +1,22 @@ -use crate::{modrinth::Version, files::download_file}; +use crate::{files::get_downloaded_versions, db::{userlist_get_all_applicable_versions_with_mods, userlist_get_all_current_versions_with_mods}}; #[allow(unused_imports)] use crate::{List, get_current_list, config::Cfg, db::userlist_get_all_downloads, input::Input}; -pub async fn download(_config: Cfg, _input: Input) -> Result<(), Box> { +pub async fn download(config: Cfg, _input: Input) -> Result<(), Box> { + + let current_list = get_current_list(config.clone())?; + println!("NO IMPLEMENTATION FOR DOWNLOAD YET"); + + let downloaded_versions = get_downloaded_versions(current_list.clone())?; + println!("DL: {:?}", downloaded_versions); + + let current_version_ids = userlist_get_all_current_versions_with_mods(config.clone(), String::from(¤t_list.id))?; + println!("CU: {:?}", current_version_ids); + + let applicable_version_ids = userlist_get_all_applicable_versions_with_mods(config, current_list.id)?; + println!("AP: {:?}", applicable_version_ids); + /* let list = get_current_list(config.clone())?; @@ -34,18 +47,4 @@ async fn download_links(_config: Cfg, _input: Input, _current_list: List, _links Ok(String::new()) } -pub async fn download_versions(current_list: List, versions: Vec) -> Result> { - - let dl_path = String::from(¤t_list.download_folder); - - for ver in versions { - let primary_file = ver.files.into_iter().find(|file| file.primary).unwrap(); - let mut splitname: Vec<&str> = primary_file.filename.split('.').collect(); - let extension = splitname.pop().ok_or("NO_FILE_EXTENSION")?; - let filename = format!("{}.mr{}.{}", splitname.join("."), ver.id, extension); - download_file(primary_file.url, current_list.clone().download_folder, filename).await?; - } - - Ok(dl_path) -} -- cgit v1.2.3