summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/update.rs18
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 @@
1use std::{io::{Error, ErrorKind}, fs::{rename, remove_file}}; 1use std::{io::{Error, ErrorKind}, fs::{rename, remove_file}};
2 2
3use 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}; 3use 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
5pub async fn update(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> { 5pub 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
129fn 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]
139async fn download_updates_test() { 135async fn download_updates_test() {
140 136