From fdd7525e5a0d298ebb8a9aa81cc19ec79e8cd113 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Thu, 17 Nov 2022 21:20:09 +0100 Subject: added --clean for update && list downloadfolder --- src/commands/setup.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/commands/setup.rs') diff --git a/src/commands/setup.rs b/src/commands/setup.rs index 8c0fcfd..be06040 100644 --- a/src/commands/setup.rs +++ b/src/commands/setup.rs @@ -1,9 +1,8 @@ use std::{fs::File, path::Path, io::{Error, ErrorKind}}; -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}; +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, s_config_update_version}, modrinth::get_raw_versions}; pub async fn setup(config: Cfg) -> Result<(), Box> { - let db_file = format!("{}/data.db", String::from(&config.data)); if !Path::new(&db_file).exists() { @@ -13,6 +12,7 @@ pub async fn setup(config: Cfg) -> Result<(), Box> { match s_config_get_version(config.clone()) { Ok(ver) => { match ver.as_str() { + "0.2" => to_03(config)?, _ => return Err(Box::new(Error::new(ErrorKind::Other, "UNKNOWN_VERSION"))) } }, @@ -33,7 +33,7 @@ async fn to_02(config: Cfg) -> Result<(), Box> { for list in lists { println!("Updating {}", list); - s_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::from("TEXT"))?; let full_list = lists_get(config.clone(), String::from(&list))?; @@ -51,3 +51,8 @@ async fn to_02(config: Cfg) -> Result<(), Box> { Ok(()) } + +fn to_03(config: Cfg) -> Result<(), Box> { + s_insert_column(config.clone(), String::from("lists"), String::from("download_folder"), String::from("TEXT"))?; + s_config_update_version(config, String::from("0.3")) +} -- cgit v1.2.3