summaryrefslogtreecommitdiff
path: root/src/commands/setup.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2022-11-17 21:20:09 +0100
committerfxqnlr <[email protected]>2022-11-17 21:20:09 +0100
commitfdd7525e5a0d298ebb8a9aa81cc19ec79e8cd113 (patch)
treeec7c7c80434b339f9442882f1e2dce6f60cc9edd /src/commands/setup.rs
parent5145dd23f1777180d8003e76f59af57643796516 (diff)
downloadmodlist-fdd7525e5a0d298ebb8a9aa81cc19ec79e8cd113.tar
modlist-fdd7525e5a0d298ebb8a9aa81cc19ec79e8cd113.tar.gz
modlist-fdd7525e5a0d298ebb8a9aa81cc19ec79e8cd113.zip
added --clean for update && list downloadfolder
Diffstat (limited to 'src/commands/setup.rs')
-rw-r--r--src/commands/setup.rs11
1 files changed, 8 insertions, 3 deletions
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 @@
1use std::{fs::File, path::Path, io::{Error, ErrorKind}}; 1use std::{fs::File, path::Path, io::{Error, ErrorKind}};
2 2
3use 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}; 3use 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};
4 4
5pub async fn setup(config: Cfg) -> Result<(), Box<dyn std::error::Error>> { 5pub async fn setup(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
6
7 let db_file = format!("{}/data.db", String::from(&config.data)); 6 let db_file = format!("{}/data.db", String::from(&config.data));
8 7
9 if !Path::new(&db_file).exists() { 8 if !Path::new(&db_file).exists() {
@@ -13,6 +12,7 @@ pub async fn setup(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
13 match s_config_get_version(config.clone()) { 12 match s_config_get_version(config.clone()) {
14 Ok(ver) => { 13 Ok(ver) => {
15 match ver.as_str() { 14 match ver.as_str() {
15 "0.2" => to_03(config)?,
16 _ => return Err(Box::new(Error::new(ErrorKind::Other, "UNKNOWN_VERSION"))) 16 _ => return Err(Box::new(Error::new(ErrorKind::Other, "UNKNOWN_VERSION")))
17 } 17 }
18 }, 18 },
@@ -33,7 +33,7 @@ async fn to_02(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
33 33
34 for list in lists { 34 for list in lists {
35 println!("Updating {}", list); 35 println!("Updating {}", list);
36 s_insert_column(config.clone(), String::from(&list), String::from("current_download"), String::new())?; 36 s_insert_column(config.clone(), String::from(&list), String::from("current_download"), String::from("TEXT"))?;
37 37
38 let full_list = lists_get(config.clone(), String::from(&list))?; 38 let full_list = lists_get(config.clone(), String::from(&list))?;
39 39
@@ -51,3 +51,8 @@ async fn to_02(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
51 51
52 Ok(()) 52 Ok(())
53} 53}
54
55fn to_03(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
56 s_insert_column(config.clone(), String::from("lists"), String::from("download_folder"), String::from("TEXT"))?;
57 s_config_update_version(config, String::from("0.3"))
58}