diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2023-10-13 03:21:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-13 03:21:46 +0200 |
commit | 6003069ebbbfeacae7b9d5adfb88c6ef41821de8 (patch) | |
tree | 10c8d96ae2bd8c9bbb0bd308fc32e1bb00165930 /src-tauri | |
parent | 1740f79673b4aad700fbd131e83bb7beab3b7a4e (diff) | |
download | FlightCore-6003069ebbbfeacae7b9d5adfb88c6ef41821de8.tar.gz FlightCore-6003069ebbbfeacae7b9d5adfb88c6ef41821de8.zip |
refactor: Move NS installation logic to module (#619)
Move Northstar installation logic to module in order to clean up `main.rs`
Diffstat (limited to 'src-tauri')
-rw-r--r-- | src-tauri/src/main.rs | 54 | ||||
-rw-r--r-- | src-tauri/src/northstar/install.rs | 43 |
2 files changed, 45 insertions, 52 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 32804192..6b0425cd 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -124,8 +124,8 @@ fn main() { check_is_northstar_outdated, verify_install_location, platform_specific::get_host_os, - install_northstar_wrapper, - update_northstar, + northstar::install::install_northstar_wrapper, + northstar::install::update_northstar, northstar::launch_northstar, northstar::launch_northstar_steam, github::release_notes::check_is_flightcore_outdated, @@ -278,56 +278,6 @@ async fn verify_install_location(game_path: String) -> bool { } } -/// Installs Northstar to the given path -#[tauri::command] -async fn install_northstar_wrapper( - window: tauri::Window, - game_install: GameInstall, - northstar_package_name: Option<String>, - version_number: Option<String>, -) -> Result<bool, String> { - log::info!("Running Northstar install"); - - // Get Northstar package name (`Northstar` vs `NorthstarReleaseCandidate`) - let northstar_package_name = northstar_package_name - .map(|name| { - if name.len() <= 1 { - "Northstar".to_string() - } else { - name - } - }) - .unwrap_or("Northstar".to_string()); - - match northstar::install::install_northstar( - window, - game_install, - northstar_package_name, - version_number, - ) - .await - { - Ok(_) => Ok(true), - Err(err) => { - log::error!("{}", err); - Err(err) - } - } -} - -/// Update Northstar install in the given path -#[tauri::command] -async fn update_northstar( - window: tauri::Window, - game_install: GameInstall, - northstar_package_name: Option<String>, -) -> Result<bool, String> { - log::info!("Updating Northstar"); - - // Simply re-run install with up-to-date version for upate - install_northstar_wrapper(window, game_install, northstar_package_name, None).await -} - /// Installs the specified mod #[tauri::command] async fn install_mod_wrapper( diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs index 757f6c68..693d7af2 100644 --- a/src-tauri/src/northstar/install.rs +++ b/src-tauri/src/northstar/install.rs @@ -29,6 +29,49 @@ struct InstallProgress { state: InstallState, } +/// Installs Northstar to the given path +#[tauri::command] +pub async fn install_northstar_wrapper( + window: tauri::Window, + game_install: GameInstall, + northstar_package_name: Option<String>, + version_number: Option<String>, +) -> Result<bool, String> { + log::info!("Running Northstar install"); + + // Get Northstar package name (`Northstar` vs `NorthstarReleaseCandidate`) + let northstar_package_name = northstar_package_name + .map(|name| { + if name.len() <= 1 { + "Northstar".to_string() + } else { + name + } + }) + .unwrap_or("Northstar".to_string()); + + match install_northstar(window, game_install, northstar_package_name, version_number).await { + Ok(_) => Ok(true), + Err(err) => { + log::error!("{}", err); + Err(err) + } + } +} + +/// Update Northstar install in the given path +#[tauri::command] +pub async fn update_northstar( + window: tauri::Window, + game_install: GameInstall, + northstar_package_name: Option<String>, +) -> Result<bool, String> { + log::info!("Updating Northstar"); + + // Simply re-run install with up-to-date version for upate + install_northstar_wrapper(window, game_install, northstar_package_name, None).await +} + /// Copied from `papa` source code and modified ///Install N* from the provided mod /// |