diff options
author | FxQnLr <[email protected]> | 2022-12-03 20:08:42 +0100 |
---|---|---|
committer | FxQnLr <[email protected]> | 2022-12-03 20:08:42 +0100 |
commit | f3f746be6c1c19c93d440bbc210dec631e2b42bb (patch) | |
tree | 562531a2929cc5f58f449652220a0abe94a0dec7 /src/commands/update.rs | |
parent | 575d2493e8e5747bf65321f7277e52211d73e387 (diff) | |
download | modlist-f3f746be6c1c19c93d440bbc210dec631e2b42bb.tar modlist-f3f746be6c1c19c93d440bbc210dec631e2b42bb.tar.gz modlist-f3f746be6c1c19c93d440bbc210dec631e2b42bb.zip |
remove mod start
Diffstat (limited to 'src/commands/update.rs')
-rw-r--r-- | src/commands/update.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/commands/update.rs b/src/commands/update.rs index be15cfa..482e588 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use std::{io::{Error, ErrorKind}, fs::{rename, remove_file}}; | 1 | use std::{io::{Error, ErrorKind}, fs::{rename, remove_file}}; |
2 | 2 | ||
3 | use crate::{config::Cfg, modrinth::{projects, Project, versions, extract_current_version, Version}, get_current_list, db::{userlist_get_all_ids, mods_get_versions, userlist_get_applicable_versions, userlist_change_versions, lists_get_all_ids, lists_get, userlist_get_current_version, userlist_add_disabled_versions, mods_change_versions}, List, input::Input, files::get_file_path, download_versions}; | 3 | use crate::{config::Cfg, modrinth::{projects, Project, versions, extract_current_version, Version}, get_current_list, db::{userlist_get_all_ids, mods_get_versions, userlist_get_applicable_versions, userlist_change_versions, lists_get_all_ids, lists_get, userlist_get_current_version, userlist_add_disabled_versions, mods_change_versions}, List, input::Input, files::{get_file_path, delete_version}, download_versions}; |
4 | 4 | ||
5 | pub async fn update(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> { | 5 | pub async fn update(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> { |
6 | 6 | ||
@@ -73,7 +73,12 @@ pub async fn update(config: Cfg, input: Input) -> Result<(), Box<dyn std::error: | |||
73 | 73 | ||
74 | //Disable old versions | 74 | //Disable old versions |
75 | for ver in current_versions { | 75 | for ver in current_versions { |
76 | if input.delete_old { delete_old(current_list.clone(), ver.0, ver.1)? } else { disable_old(config.clone(), current_list.clone(), ver.0, ver.1)? }; | 76 | if input.delete_old { |
77 | println!("Deleting version {} for mod {}", ver.0, ver.1); | ||
78 | delete_version(current_list.clone(), ver.0)?; | ||
79 | } else { | ||
80 | disable_old(config.clone(), current_list.clone(), ver.0, ver.1)? | ||
81 | }; | ||
77 | } | 82 | } |
78 | } | 83 | } |
79 | 84 | ||
@@ -126,15 +131,6 @@ fn disable_old(config: Cfg, current_list: List, versionid: String, mod_id: Strin | |||
126 | Ok(()) | 131 | Ok(()) |
127 | } | 132 | } |
128 | 133 | ||
129 | fn delete_old(current_list: List, versionid: String, mod_id: String) -> Result<(), Box<dyn std::error::Error>> { | ||
130 | println!("Deleting version {} for mod {}", versionid, mod_id); | ||
131 | let file = get_file_path(current_list, String::from(&versionid))?; | ||
132 | |||
133 | remove_file(file)?; | ||
134 | |||
135 | Ok(()) | ||
136 | } | ||
137 | |||
138 | #[tokio::test] | 134 | #[tokio::test] |
139 | async fn download_updates_test() { | 135 | async fn download_updates_test() { |
140 | 136 | ||