diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2023-05-07 01:42:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-07 01:42:02 +0200 |
commit | 39240807a19538142fb46f23f61f54ded98a22aa (patch) | |
tree | 6ef65724b803ede99eba3021e1d7bf4c4e4cabbd /src-tauri/src/main.rs | |
parent | b2d64fe32fa0015d383a82ec8d637e08286e37ee (diff) | |
download | FlightCore-39240807a19538142fb46f23f61f54ded98a22aa.tar.gz FlightCore-39240807a19538142fb46f23f61f54ded98a22aa.zip |
refactor: Prepare code for installing older Northstar versions (#305)
* refactor: Rename function
Rename `install_northstar` to `install_latest_northstar` to better
indicate what it does
* refactor: Have updater just call installer
* refactor: Move package selection to calling func
During installation, package should already be known so get package
name earlier as opposed to passing `Option<T>`
* chore: Format fix
* refactor: Allow passing NS version to install
If no version is passed, fallback is to latest
* refactor: Rename function
Back to `install_northstar` from `install_latest_northstar` as the
function can now install any Northstar version
* refactor: Do a borrow instead of clone
* refactor: Use `map` and `unwrap_or`
instead of `match`
Diffstat (limited to 'src-tauri/src/main.rs')
-rw-r--r-- | src-tauri/src/main.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 2e4b3370..1ba12474 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -327,9 +327,22 @@ async fn install_northstar_caller( window: tauri::Window, game_path: String, northstar_package_name: Option<String>, + version_number: Option<String>, ) -> Result<bool, String> { log::info!("Running"); - match install_northstar(window, &game_path, northstar_package_name).await { + + // 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_path, northstar_package_name, version_number).await { Ok(_) => Ok(true), Err(err) => { log::error!("{}", err); @@ -348,13 +361,7 @@ async fn update_northstar_caller( log::info!("Updating Northstar"); // Simply re-run install with up-to-date version for upate - match install_northstar(window, &game_path, northstar_package_name).await { - Ok(_) => Ok(true), - Err(err) => { - log::error!("{}", err); - Err(err) - } - } + install_northstar_caller(window, game_path, northstar_package_name, None).await } #[tauri::command] |