diff options
author | fxqnlr <[email protected]> | 2023-02-05 09:23:29 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2023-02-05 09:23:29 +0100 |
commit | ff23a11e632812b685f594324e6004c6da81cd4d (patch) | |
tree | 2b503cb25d8ebfbc33d449860e1903a4c6c9513f /src/commands/io.rs | |
parent | 2f4b5f1584f88491ea4a6902d69382a0e73aa76d (diff) | |
download | modlist-ff23a11e632812b685f594324e6004c6da81cd4d.tar modlist-ff23a11e632812b685f594324e6004c6da81cd4d.tar.gz modlist-ff23a11e632812b685f594324e6004c6da81cd4d.zip |
Fixed update shit not correctly updating
Diffstat (limited to 'src/commands/io.rs')
-rw-r--r-- | src/commands/io.rs | 20 |
1 files changed, 10 insertions, 10 deletions
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; | |||
2 | use std::io::prelude::*; | 2 | use std::io::prelude::*; |
3 | use serde::{Serialize, Deserialize}; | 3 | use serde::{Serialize, Deserialize}; |
4 | 4 | ||
5 | 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}; | 5 | 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}; |
6 | 6 | ||
7 | #[derive(Debug, Serialize, Deserialize)] | 7 | #[derive(Debug, Serialize, Deserialize)] |
8 | struct Export { | 8 | struct Export { |
@@ -24,7 +24,7 @@ impl ExportList { | |||
24 | let list = lists_get(config.clone(), String::from(&list_id))?; | 24 | let list = lists_get(config.clone(), String::from(&list_id))?; |
25 | 25 | ||
26 | let mut dl_folder = None; | 26 | let mut dl_folder = None; |
27 | if download == true { dl_folder = Some(list.download_folder) }; | 27 | if download{ dl_folder = Some(list.download_folder) }; |
28 | 28 | ||
29 | let mods = userlist_get_all_ids(config, list_id)?.join("|"); | 29 | let mods = userlist_get_all_ids(config, list_id)?.join("|"); |
30 | 30 | ||
@@ -51,7 +51,7 @@ fn export(config: Cfg, input: Input) -> MLE<()> { | |||
51 | } | 51 | } |
52 | let mut lists: Vec<ExportList> = vec![]; | 52 | let mut lists: Vec<ExportList> = vec![]; |
53 | for list_id in list_ids { | 53 | for list_id in list_ids { |
54 | lists.push(ExportList::from(config.clone(), String::from(list_id), true)?); | 54 | lists.push(ExportList::from(config.clone(), list_id, true)?); |
55 | } | 55 | } |
56 | 56 | ||
57 | let toml = toml::to_string( &Export { lists } )?; | 57 | let toml = toml::to_string( &Export { lists } )?; |
@@ -59,7 +59,7 @@ fn export(config: Cfg, input: Input) -> MLE<()> { | |||
59 | let filestr = dirs::home_dir().unwrap().join("mlexport.toml"); | 59 | let filestr = dirs::home_dir().unwrap().join("mlexport.toml"); |
60 | 60 | ||
61 | let mut file = File::create(devdir(filestr.into_os_string().into_string().unwrap().as_str()))?; | 61 | let mut file = File::create(devdir(filestr.into_os_string().into_string().unwrap().as_str()))?; |
62 | file.write_all(&toml.as_bytes())?; | 62 | file.write_all(toml.as_bytes())?; |
63 | 63 | ||
64 | Ok(()) | 64 | Ok(()) |
65 | } | 65 | } |
@@ -67,8 +67,8 @@ fn export(config: Cfg, input: Input) -> MLE<()> { | |||
67 | async fn import(config: Cfg, input: Input) -> MLE<()> { | 67 | async fn import(config: Cfg, input: Input) -> MLE<()> { |
68 | 68 | ||
69 | let filestr: String = match input.file { | 69 | let filestr: String = match input.file { |
70 | Some(args) => String::from(args), | 70 | Some(args) => args, |
71 | None => String::from(devdir(dirs::home_dir().unwrap().join("mlexport.toml").into_os_string().into_string().unwrap().as_str())), | 71 | None => devdir(dirs::home_dir().unwrap().join("mlexport.toml").into_os_string().into_string().unwrap().as_str()), |
72 | }; | 72 | }; |
73 | 73 | ||
74 | let mut file = File::open(filestr)?; | 74 | let mut file = File::open(filestr)?; |
@@ -76,17 +76,17 @@ async fn import(config: Cfg, input: Input) -> MLE<()> { | |||
76 | file.read_to_string(&mut content)?; | 76 | file.read_to_string(&mut content)?; |
77 | let export: Export = toml::from_str(&content)?; | 77 | let export: Export = toml::from_str(&content)?; |
78 | 78 | ||
79 | println!("{:#?}", export); | ||
80 | |||
81 | for exportlist in export.lists { | 79 | for exportlist in export.lists { |
82 | 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() }; | 80 | 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() }; |
83 | lists_insert(config.clone(), list.id.clone(), list.mc_version.clone(), list.modloader.clone(), String::from(&list.download_folder))?; | 81 | lists_insert(config.clone(), list.id.clone(), list.mc_version.clone(), list.modloader.clone(), String::from(&list.download_folder))?; |
84 | let mods: Vec<&str> = exportlist.mods.split("|").collect(); | 82 | let mods: Vec<&str> = exportlist.mods.split('|').collect(); |
85 | let mut mod_ids = vec![]; | 83 | let mut mod_ids = vec![]; |
86 | for mod_id in mods { | 84 | for mod_id in mods { |
87 | mod_ids.push(String::from(mod_id)); | 85 | mod_ids.push(String::from(mod_id)); |
88 | }; | 86 | }; |
89 | //mod_add(config.clone(), mod_ids, list.clone(), false).await?; | 87 | //TODO impl set_version and good direct download |
88 | //TODO impl all at once, dafuck | ||
89 | mods_add(config.clone(), mod_ids, list, input.direct_download, false).await?; | ||
90 | } | 90 | } |
91 | Ok(()) | 91 | Ok(()) |
92 | } | 92 | } |