summaryrefslogtreecommitdiff
path: root/src/db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/db.rs b/src/db.rs
index 3f05772..d823018 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -32,7 +32,6 @@ pub fn mods_get_all_ids(config: Cfg) -> Result<Vec<String>, Box<dyn std::error::
32 })?; 32 })?;
33 33
34 for id in id_iter { 34 for id in id_iter {
35 //println!("Found id {:?}", id.as_ref().unwrap());
36 mods.push(id?); 35 mods.push(id?);
37 } 36 }
38 37
@@ -53,7 +52,6 @@ pub fn mods_get_id(config: Cfg, name: String) -> Result<String, Box<dyn std::err
53 })?; 52 })?;
54 53
55 for id in id_iter { 54 for id in id_iter {
56 //println!("Found id {:?}", id.as_ref().unwrap());
57 mod_id = id?; 55 mod_id = id?;
58 }; 56 };
59 57
@@ -74,7 +72,6 @@ pub fn mods_get_name(config: Cfg, id: String) -> Result<String, Box<dyn std::err
74 })?; 72 })?;
75 73
76 for name in name_iter { 74 for name in name_iter {
77 //println!("Found id {:?}", id.as_ref().unwrap());
78 mod_name = name?; 75 mod_name = name?;
79 }; 76 };
80 77
@@ -394,6 +391,14 @@ pub fn lists_get(config: Cfg, list_id: String) -> Result<List, Box<dyn std::erro
394 Ok(list) 391 Ok(list)
395} 392}
396 393
394pub fn lists_version(config: Cfg, list_id: String, version: String) -> Result<(), Box<dyn std::error::Error>> {
395 let data = devdir(format!("{}/data.db", config.data).as_str());
396 let connection = Connection::open(data).unwrap();
397
398 connection.execute("UPDATE lists SET mc_version = ? WHERE id = ?", [version, list_id])?;
399 Ok(())
400}
401
397pub fn lists_get_all_ids(config: Cfg) -> Result<Vec<String>, Box<dyn std::error::Error>> { 402pub fn lists_get_all_ids(config: Cfg) -> Result<Vec<String>, Box<dyn std::error::Error>> {
398 let data = devdir(format!("{}/data.db", config.data).as_str()); 403 let data = devdir(format!("{}/data.db", config.data).as_str());
399 let connection = Connection::open(data).unwrap(); 404 let connection = Connection::open(data).unwrap();
@@ -510,7 +515,7 @@ pub fn db_setup(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
510 "CREATE TABLE 'user_config' ( 'id' TEXT, 'value' TEXT ); 515 "CREATE TABLE 'user_config' ( 'id' TEXT, 'value' TEXT );
511 CREATE TABLE 'mods' ( 'id' TEXT, 'name' TEXT, 'versions' TEXT ); 516 CREATE TABLE 'mods' ( 'id' TEXT, 'name' TEXT, 'versions' TEXT );
512 CREATE TABLE 'lists' ( 'id' TEXT, 'mc_version' TEXT, 'modloader' TEXT, 'download_folder' TEXT ); 517 CREATE TABLE 'lists' ( 'id' TEXT, 'mc_version' TEXT, 'modloader' TEXT, 'download_folder' TEXT );
513 INSERT INTO 'user_config' VALUES ( 'db_version', '0.3' ); 518 INSERT INTO 'user_config' VALUES ( 'db_version', '0.4' );
514 INSERT INTO 'user_config' VALUES ( 'current_list', '...' )", 519 INSERT INTO 'user_config' VALUES ( 'current_list', '...' )",
515 )?; 520 )?;
516 521