From 2d7e0a2fbf1c8a4187e2bf3fdcd592631ab273a0 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Fri, 26 May 2023 17:40:27 +0200 Subject: added full progress? cargo fmt --- src/db.rs | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'src/db.rs') diff --git a/src/db.rs b/src/db.rs index 1f3ad4c..f627ef4 100644 --- a/src/db.rs +++ b/src/db.rs @@ -120,9 +120,7 @@ pub fn mods_get_info(config: &Cfg, id: &str) -> MLE { } } -pub fn mods_remove(config: &Cfg, id: String) -> MLE<()> { - // println!("Removing mod {} from database", id); - +pub fn mods_remove(config: &Cfg, id: &str) -> MLE<()> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -233,7 +231,10 @@ pub fn userlist_get_all_ids(config: &Cfg, list_id: &str) -> MLE> { } match mod_ids.is_empty() { - true => Err(MLError::new(ErrorType::DBError, &format!("NO_MODS_USERLIST{}", list_id))), + true => Err(MLError::new( + ErrorType::DBError, + &format!("NO_MODS_USERLIST{}", list_id), + )), false => Ok(mod_ids), } } @@ -325,10 +326,7 @@ pub fn userlist_get_current_version(config: &Cfg, list_id: &str, mod_id: &str) - } } -pub fn userlist_get_all_current_version_ids( - config: &Cfg, - list_id: String, -) -> MLE> { +pub fn userlist_get_all_current_version_ids(config: &Cfg, list_id: String) -> MLE> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -342,10 +340,7 @@ pub fn userlist_get_all_current_version_ids( } if versions.is_empty() { - return Err(MLError::new( - ErrorType::DBError, - "NO_MODS_ON_LIST", - )); + return Err(MLError::new(ErrorType::DBError, "NO_MODS_ON_LIST")); }; Ok(versions) @@ -441,7 +436,11 @@ pub fn userlist_add_disabled_versions( Ok(()) } -pub fn userlist_get_disabled_versions(config: &Cfg, list_id: String, mod_id: String) -> MLE { +pub fn userlist_get_disabled_versions( + config: &Cfg, + list_id: String, + mod_id: String, +) -> MLE { let data = format!("{}/data.db", config.data); let connection = Connection::open(data).unwrap(); @@ -504,19 +503,14 @@ pub fn lists_insert( connection.execute( "INSERT INTO lists VALUES (?1, ?2, ?3, ?4)", - [ - id, - mc_version, - &mod_loader.to_string(), - download_folder, - ], + [id, mc_version, &mod_loader.to_string(), download_folder], )?; connection.execute(format!("CREATE TABLE {}( 'mod_id' TEXT, 'current_version' TEXT, 'applicable_versions' BLOB, 'current_download' TEXT, 'disabled_versions' TEXT DEFAULT 'NONE', 'set_version' INTEGER, CONSTRAINT {}_PK PRIMARY KEY (mod_id) )", id, id).as_str(), [])?; Ok(()) } -pub fn lists_remove(config: &Cfg, id: String) -> MLE<()> { +pub fn lists_remove(config: &Cfg, id: &str) -> MLE<()> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -593,7 +587,7 @@ pub fn lists_get_all_ids(config: &Cfg) -> MLE> { } //config -pub fn config_change_current_list(config: &Cfg, id: String) -> MLE<()> { +pub fn config_change_current_list(config: &Cfg, id: &str) -> MLE<()> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -655,7 +649,10 @@ pub fn s_config_create_version(config: &Cfg) -> Result<(), Box Result<(), Box> { +pub fn s_config_update_version( + config: &Cfg, + ver: String, +) -> Result<(), Box> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; -- cgit v1.2.3