From ff23a11e632812b685f594324e6004c6da81cd4d Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Sun, 5 Feb 2023 09:23:29 +0100 Subject: Fixed update shit not correctly updating --- src/commands/io.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/commands/io.rs') diff --git a/src/commands/io.rs b/src/commands/io.rs index 4835e3d..44604d1 100644 --- a/src/commands/io.rs +++ b/src/commands/io.rs @@ -2,7 +2,7 @@ use std::fs::File; use std::io::prelude::*; use serde::{Serialize, Deserialize}; -use crate::{input::{Input, IoOptions}, db::{lists_get, userlist_get_all_ids, lists_get_all_ids, lists_insert}, config::Cfg, Modloader, /*mod_add,*/ List, devdir, error::MLE}; +use crate::{input::{Input, IoOptions}, db::{lists_get, userlist_get_all_ids, lists_get_all_ids, lists_insert}, config::Cfg, Modloader, List, devdir, error::MLE, mods_add}; #[derive(Debug, Serialize, Deserialize)] struct Export { @@ -24,7 +24,7 @@ impl ExportList { let list = lists_get(config.clone(), String::from(&list_id))?; let mut dl_folder = None; - if download == true { dl_folder = Some(list.download_folder) }; + if download{ dl_folder = Some(list.download_folder) }; let mods = userlist_get_all_ids(config, list_id)?.join("|"); @@ -51,7 +51,7 @@ fn export(config: Cfg, input: Input) -> MLE<()> { } let mut lists: Vec = vec![]; for list_id in list_ids { - lists.push(ExportList::from(config.clone(), String::from(list_id), true)?); + lists.push(ExportList::from(config.clone(), list_id, true)?); } let toml = toml::to_string( &Export { lists } )?; @@ -59,7 +59,7 @@ fn export(config: Cfg, input: Input) -> MLE<()> { let filestr = dirs::home_dir().unwrap().join("mlexport.toml"); let mut file = File::create(devdir(filestr.into_os_string().into_string().unwrap().as_str()))?; - file.write_all(&toml.as_bytes())?; + file.write_all(toml.as_bytes())?; Ok(()) } @@ -67,8 +67,8 @@ fn export(config: Cfg, input: Input) -> MLE<()> { async fn import(config: Cfg, input: Input) -> MLE<()> { let filestr: String = match input.file { - Some(args) => String::from(args), - None => String::from(devdir(dirs::home_dir().unwrap().join("mlexport.toml").into_os_string().into_string().unwrap().as_str())), + Some(args) => args, + None => devdir(dirs::home_dir().unwrap().join("mlexport.toml").into_os_string().into_string().unwrap().as_str()), }; let mut file = File::open(filestr)?; @@ -76,17 +76,17 @@ async fn import(config: Cfg, input: Input) -> MLE<()> { file.read_to_string(&mut content)?; let export: Export = toml::from_str(&content)?; - println!("{:#?}", export); - for exportlist in export.lists { let list = List { id: exportlist.id, mc_version: exportlist.mc_version, modloader: Modloader::from(&exportlist.launcher)?, download_folder: exportlist.download_folder.ok_or("NO_DL").unwrap() }; lists_insert(config.clone(), list.id.clone(), list.mc_version.clone(), list.modloader.clone(), String::from(&list.download_folder))?; - let mods: Vec<&str> = exportlist.mods.split("|").collect(); + let mods: Vec<&str> = exportlist.mods.split('|').collect(); let mut mod_ids = vec![]; for mod_id in mods { mod_ids.push(String::from(mod_id)); }; - //mod_add(config.clone(), mod_ids, list.clone(), false).await?; + //TODO impl set_version and good direct download + //TODO impl all at once, dafuck + mods_add(config.clone(), mod_ids, list, input.direct_download, false).await?; } Ok(()) } -- cgit v1.2.3