diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-08-03 19:46:54 +0200 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-08-03 19:46:54 +0200 |
commit | 439574d9b7f2ac4a95d97cb56e57cf152bb01ad2 (patch) | |
tree | 937bad8bc0e7c443c7576046dc3afef70d0d0e59 /src-tauri/src/github | |
parent | 869300c848429d18734fd0d02f4c277f21357568 (diff) | |
parent | efb193b517087d47f30f0542517c389bbfe5cde1 (diff) | |
download | FlightCore-439574d9b7f2ac4a95d97cb56e57cf152bb01ad2.tar.gz FlightCore-439574d9b7f2ac4a95d97cb56e57cf152bb01ad2.zip |
Merge branch 'main' into feat/launch-parameters
Diffstat (limited to 'src-tauri/src/github')
-rw-r--r-- | src-tauri/src/github/pull_requests.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src-tauri/src/github/pull_requests.rs b/src-tauri/src/github/pull_requests.rs index c3079cfd..ccb45dff 100644 --- a/src-tauri/src/github/pull_requests.rs +++ b/src-tauri/src/github/pull_requests.rs @@ -2,6 +2,7 @@ use crate::github::release_notes::fetch_github_releases_api; use crate::check_is_valid_game_path; use crate::constants::{APP_USER_AGENT, PULLS_API_ENDPOINT_LAUNCHER, PULLS_API_ENDPOINT_MODS}; +use crate::GameInstall; use anyhow::anyhow; use serde::{Deserialize, Serialize}; use std::fs::File; @@ -231,10 +232,10 @@ fn add_batch_file(game_install_path: &str) { #[tauri::command] pub async fn apply_launcher_pr( pull_request: PullsApiResponseElement, - game_install_path: &str, + game_install: GameInstall, ) -> Result<(), String> { // Exit early if wrong game path - check_is_valid_game_path(game_install_path)?; + check_is_valid_game_path(&game_install.game_path)?; // get download link let download_url = match get_launcher_download_link(pull_request.head.sha.clone()).await { @@ -254,7 +255,7 @@ pub async fn apply_launcher_pr( let extract_directory = format!( "{}/___flightcore-temp/download-dir/launcher-pr-{}", - game_install_path, pull_request.number + game_install.game_path, pull_request.number ); match std::fs::create_dir_all(extract_directory.clone()) { Ok(_) => (), @@ -281,7 +282,7 @@ pub async fn apply_launcher_pr( let files_to_copy = vec!["NorthstarLauncher.exe", "Northstar.dll"]; for file_name in files_to_copy { let source_file_path = format!("{}/{}", extract_directory, file_name); - let destination_file_path = format!("{}/{}", game_install_path, file_name); + let destination_file_path = format!("{}/{}", game_install.game_path, file_name); match std::fs::copy(source_file_path, destination_file_path) { Ok(_result) => (), Err(err) => { @@ -312,10 +313,10 @@ pub async fn apply_launcher_pr( #[tauri::command] pub async fn apply_mods_pr( pull_request: PullsApiResponseElement, - game_install_path: &str, + game_install: GameInstall, ) -> Result<(), String> { // Exit early if wrong game path - check_is_valid_game_path(game_install_path)?; + check_is_valid_game_path(&game_install.game_path)?; let download_url = match get_mods_download_link(pull_request) { Ok(url) => url, @@ -327,7 +328,10 @@ pub async fn apply_mods_pr( Err(err) => return Err(err.to_string()), }; - let profile_folder = format!("{}/R2Northstar-PR-test-managed-folder", game_install_path); + let profile_folder = format!( + "{}/R2Northstar-PR-test-managed-folder", + game_install.game_path + ); // Delete previously managed folder if std::fs::remove_dir_all(profile_folder.clone()).is_err() { @@ -352,7 +356,7 @@ pub async fn apply_mods_pr( } }; // Add batch file to launch right profile - add_batch_file(game_install_path); + add_batch_file(&game_install.game_path); log::info!("All done with installing mods PR"); Ok(()) |