aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/mod_management/mod.rs
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-10-13 14:07:43 +0200
committerGitHub <noreply@github.com>2023-10-13 14:07:43 +0200
commitfbaa5d7ad4d3674f991ae73c672190cdd6ddac01 (patch)
tree2439e5e4856a350bc6f074f5963a27c825996a01 /src-tauri/src/mod_management/mod.rs
parentb58d8d138919ec911369b644d7a49c94215c77a9 (diff)
downloadFlightCore-fbaa5d7ad4d3674f991ae73c672190cdd6ddac01.tar.gz
FlightCore-fbaa5d7ad4d3674f991ae73c672190cdd6ddac01.zip
refactor: Move `install_mod_wrapper` (#627)
Move `install_mod_wrapper` to `mod_management` module to clean up `main.rs`.
Diffstat (limited to 'src-tauri/src/mod_management/mod.rs')
-rw-r--r--src-tauri/src/mod_management/mod.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs
index a9826522..ab639b11 100644
--- a/src-tauri/src/mod_management/mod.rs
+++ b/src-tauri/src/mod_management/mod.rs
@@ -89,6 +89,30 @@ impl std::ops::Deref for TempFile {
}
}
+/// Installs the specified mod
+#[tauri::command]
+pub async fn install_mod_wrapper(
+ game_install: GameInstall,
+ thunderstore_mod_string: String,
+) -> Result<(), String> {
+ match fc_download_mod_and_install(&game_install, &thunderstore_mod_string).await {
+ Ok(()) => (),
+ Err(err) => {
+ log::warn!("{err}");
+ return Err(err);
+ }
+ };
+ match crate::repair_and_verify::clean_up_download_folder(&game_install, false) {
+ Ok(()) => Ok(()),
+ Err(err) => {
+ log::info!("Failed to delete download folder due to {}", err);
+ // Failure to delete download folder is not an error in mod install
+ // As such ignore. User can still force delete if need be
+ Ok(())
+ }
+ }
+}
+
/// Returns a serde json object of the parsed `enabledmods.json` file
pub fn get_enabled_mods(game_install: &GameInstall) -> Result<serde_json::value::Value, String> {
let enabledmods_json_path = format!(