From 96d400ca1275bf8444e5ad4dc6c8a06b01c3ea9d Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 24 Apr 2023 19:00:04 +0200 Subject: add auto create dirs, database and default config --- src/commands/download.rs | 2 +- src/commands/mod.rs | 2 -- src/commands/setup.rs | 70 ------------------------------------------------ 3 files changed, 1 insertion(+), 73 deletions(-) delete mode 100644 src/commands/setup.rs (limited to 'src/commands') diff --git a/src/commands/download.rs b/src/commands/download.rs index 9434591..1a8eb8f 100644 --- a/src/commands/download.rs +++ b/src/commands/download.rs @@ -23,7 +23,7 @@ pub async fn download(config: Cfg, all_lists: bool, clean: bool, delete_old: boo for current_list in liststack { let downloaded_versions = get_downloaded_versions(current_list.clone())?; - println!("To download: {:#?}", downloaded_versions); + // println!("To download: {:#?}", downloaded_versions); let current_version_ids = match userlist_get_all_current_versions_with_mods( config.clone(), String::from(¤t_list.id), diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 1c7c012..0f13056 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -2,12 +2,10 @@ pub mod download; pub mod io; pub mod list; pub mod modification; -pub mod setup; pub mod update; pub use download::*; pub use io::*; pub use list::*; pub use modification::*; -pub use setup::*; pub use update::*; diff --git a/src/commands/setup.rs b/src/commands/setup.rs deleted file mode 100644 index 34da2f8..0000000 --- a/src/commands/setup.rs +++ /dev/null @@ -1,70 +0,0 @@ -use std::{fs::File, path::Path}; - -use crate::{config::Cfg, db::db_setup, error::MLE}; - -pub async fn setup(config: Cfg) -> MLE<()> { - let db_file = format!("{}/data.db", config.data); - - if !Path::new(&db_file).exists() { - create(config, db_file)?; - } - - /* - match s_config_get_version(config.clone()) { - Ok(ver) => { - match ver.as_str() { - "0.2" => to_03(config)?, - "0.3" => to_04(config)?, - _ => return Err(MLError::new(ErrorType::Other, "UNKNOWN_VERSION")) - } - }, - Err(..) => to_02(config).await? - }; - */ - - Ok(()) -} - -fn create(config: Cfg, db_file: String) -> MLE<()> { - println!("Create database"); - - File::create(db_file)?; - db_setup(config)?; - Ok(()) -} - -//async fn to_02(config: Cfg) -> Result<(), Box> { -// let lists = lists_get_all_ids(config.clone())?; -// -// for list in lists { -// println!("Updating {}", list); -// s_insert_column(config.clone(), String::from(&list), String::from("current_download"), String::from("TEXT"), None)?; -// -// let full_list = lists_get(config.clone(), String::from(&list))?; -// -// let versions = userlist_get_all_current_version_ids(config.clone(), full_list.clone().id)?; -// -// let raw_versions = get_raw_versions(String::from(&config.apis.modrinth), versions).await; -// -// for ver in raw_versions { -// println!("Adding link for {}", ver.project_id); -// let file = ver.files.into_iter().find(|f| f.primary).unwrap(); -// s_userlist_update_download(config.clone(), String::from(&full_list.id), ver.project_id, file.url)?; -// } -// }; -// s_config_create_version(config)?; -// -// Ok(()) -//} -// -//fn to_03(config: Cfg) -> Result<(), Box> { -// s_insert_column(config.clone(), String::from("lists"), String::from("download_folder"), String::from("TEXT"), None)?; -// s_config_update_version(config, String::from("0.3")) -//} -// -//fn to_04(config: Cfg) -> Result<(), Box> { -// for list_id in lists_get_all_ids(config.clone())? { -// s_insert_column(config.clone(), list_id, String::from("disabled_versions"), String::from("TEXT"), Some(String::from("NONE")))?; -// } -// s_config_update_version(config, String::from("0.4")) -//} -- cgit v1.2.3