diff options
author | Jan <sentrycraft123@gmail.com> | 2023-07-31 12:13:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-31 12:13:17 +0200 |
commit | 3563a0bc4748b7c14cbff2240af401fab9d4dc5d (patch) | |
tree | d1af032fefb06ba0e523e4643e6894d841a0410c /src-tauri/src | |
parent | c73d4862c6a362f443c2db7d93b2cfaf51b42cff (diff) | |
download | FlightCore-3563a0bc4748b7c14cbff2240af401fab9d4dc5d.tar.gz FlightCore-3563a0bc4748b7c14cbff2240af401fab9d4dc5d.zip |
refactor: Migrate install related functions to `GameInstall` (#457)
This allows for later extending for installing in the appropriate profile
Diffstat (limited to 'src-tauri/src')
-rw-r--r-- | src-tauri/src/main.rs | 8 | ||||
-rw-r--r-- | src-tauri/src/northstar/install.rs | 20 |
2 files changed, 13 insertions, 15 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 5e6f53ba..9e812683 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -296,7 +296,7 @@ async fn verify_install_location(game_path: String) -> bool { #[tauri::command] async fn install_northstar_caller( window: tauri::Window, - game_path: String, + game_install: GameInstall, northstar_package_name: Option<String>, version_number: Option<String>, ) -> Result<bool, String> { @@ -315,7 +315,7 @@ async fn install_northstar_caller( match northstar::install::install_northstar( window, - &game_path, + game_install, northstar_package_name, version_number, ) @@ -333,13 +333,13 @@ async fn install_northstar_caller( #[tauri::command] async fn update_northstar( window: tauri::Window, - game_path: String, + 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_caller(window, game_path, northstar_package_name, None).await + install_northstar_caller(window, game_install, northstar_package_name, None).await } /// Installs the specified mod diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs index 2d96b00e..002548c1 100644 --- a/src-tauri/src/northstar/install.rs +++ b/src-tauri/src/northstar/install.rs @@ -33,10 +33,13 @@ struct InstallProgress { async fn do_install( window: tauri::Window, nmod: &thermite::model::ModVersion, - game_path: &std::path::Path, + game_install: GameInstall, ) -> Result<()> { let filename = format!("northstar-{}.zip", nmod.version); - let download_directory = format!("{}/___flightcore-temp-download-dir/", game_path.display()); + let download_directory = format!( + "{}/___flightcore-temp-download-dir/", + game_install.game_path + ); log::info!( "Attempting to create temporary directory {}", @@ -91,7 +94,7 @@ async fn do_install( .unwrap(); log::info!("Extracting Northstar..."); - extract(nfile, game_path)?; + extract(nfile, std::path::Path::new(&game_install.game_path))?; // Delete old copy log::info!("Delete temp folder again"); @@ -114,7 +117,7 @@ async fn do_install( pub async fn install_northstar( window: tauri::Window, - game_path: &str, + game_install: GameInstall, northstar_package_name: String, version_number: Option<String>, ) -> Result<String, String> { @@ -134,15 +137,10 @@ pub async fn install_northstar( // Use passed version or latest if no version was passed let version = version_number.as_ref().unwrap_or(&nmod.latest); + let game_path = game_install.game_path.clone(); log::info!("Install path \"{}\"", game_path); - match do_install( - window, - nmod.versions.get(version).unwrap(), - std::path::Path::new(game_path), - ) - .await - { + match do_install(window, nmod.versions.get(version).unwrap(), game_install).await { Ok(_) => (), Err(err) => { if game_path |