From 889dc4f87b05d838b25428478a8c42dac454a5cf Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 7 Nov 2022 22:29:35 +0100 Subject: finished rusqlite; added all db tests --- src/commands/setup.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/commands/setup.rs') diff --git a/src/commands/setup.rs b/src/commands/setup.rs index 0940959..8c0fcfd 100644 --- a/src/commands/setup.rs +++ b/src/commands/setup.rs @@ -1,6 +1,6 @@ use std::{fs::File, path::Path, io::{Error, ErrorKind}}; -use crate::{config::Cfg, db::{db_setup, user_dbversion, create_dbversion, insert_column, get_lists, get_list, get_current_versions, insert_dl_link}, modrinth::get_raw_versions}; +use crate::{config::Cfg, db::{db_setup, s_config_get_version, s_config_create_version, s_insert_column, lists_get_all_ids, lists_get, userlist_get_all_current_version_ids, s_userlist_update_download}, modrinth::get_raw_versions}; pub async fn setup(config: Cfg) -> Result<(), Box> { @@ -10,7 +10,7 @@ pub async fn setup(config: Cfg) -> Result<(), Box> { return create(config, db_file); } - match user_dbversion(config.clone()) { + match s_config_get_version(config.clone()) { Ok(ver) => { match ver.as_str() { _ => return Err(Box::new(Error::new(ErrorKind::Other, "UNKNOWN_VERSION"))) @@ -29,26 +29,25 @@ fn create(config: Cfg, db_file: String) -> Result<(), Box } async fn to_02(config: Cfg) -> Result<(), Box> { - let lists = get_lists(config.clone())?; + let lists = lists_get_all_ids(config.clone())?; for list in lists { println!("Updating {}", list); - insert_column(config.clone(), String::from(&list), String::from("current_download"), String::new())?; + s_insert_column(config.clone(), String::from(&list), String::from("current_download"), String::new())?; - let full_list = get_list(config.clone(), String::from(&list))?; + let full_list = lists_get(config.clone(), String::from(&list))?; - let versions = get_current_versions(config.clone(), full_list.clone())?; + 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(); - insert_dl_link(config.clone(), full_list.clone(), ver.project_id, file.url)?; + s_userlist_update_download(config.clone(), String::from(&full_list.id), ver.project_id, file.url)?; } }; - create_dbversion(config)?; - + s_config_create_version(config)?; Ok(()) } -- cgit v1.2.3