aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/northstar
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-10-13 03:21:46 +0200
committerGitHub <noreply@github.com>2023-10-13 03:21:46 +0200
commit6003069ebbbfeacae7b9d5adfb88c6ef41821de8 (patch)
tree10c8d96ae2bd8c9bbb0bd308fc32e1bb00165930 /src-tauri/src/northstar
parent1740f79673b4aad700fbd131e83bb7beab3b7a4e (diff)
downloadFlightCore-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/src/northstar')
-rw-r--r--src-tauri/src/northstar/install.rs43
1 files changed, 43 insertions, 0 deletions
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
///