From cc255628361c6da04f39256ebfd4c647be11a613 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 3 Aug 2023 19:19:42 +0200 Subject: fix: Add extract dir to cleanup (#466) Add extract dir to cleanup --- src-tauri/src/repair_and_verify/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs index 29cc9613..6b9d3a98 100644 --- a/src-tauri/src/repair_and_verify/mod.rs +++ b/src-tauri/src/repair_and_verify/mod.rs @@ -40,9 +40,10 @@ pub fn clean_up_download_folder( game_install: &GameInstall, force: bool, ) -> Result<(), anyhow::Error> { - const TEMPORARY_DIRECTORIES: [&str; 3] = [ + const TEMPORARY_DIRECTORIES: [&str; 4] = [ "___flightcore-temp-download-dir", "___flightcore-temp/download-dir", + "___flightcore-temp/extract-dir", "___flightcore-temp", ]; -- cgit v1.2.3 From e75f5f8baf5169d37962fadbac6609146900e070 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 3 Aug 2023 19:37:04 +0200 Subject: refactor: Use `GameInstall` object for PR install functions (#467) Passes the whole `GameInstall` object instead of individual path to functions related to PR installs. This is done in preparation for #444 --- src-tauri/src/github/pull_requests.rs | 20 ++++++++++++-------- src-vue/src/plugins/modules/pull_requests.ts | 4 ++-- 2 files changed, 14 insertions(+), 10 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(()) diff --git a/src-vue/src/plugins/modules/pull_requests.ts b/src-vue/src/plugins/modules/pull_requests.ts index 3f3ba259..4caec0b0 100644 --- a/src-vue/src/plugins/modules/pull_requests.ts +++ b/src-vue/src/plugins/modules/pull_requests.ts @@ -54,7 +54,7 @@ export const pullRequestModule = { // Send notification telling the user to wait for the process to finish const notification = showNotification(`Installing launcher PR ${pull_request.number}`, 'Please wait', 'info', 0); - await invoke("apply_launcher_pr", { pullRequest: pull_request, gameInstallPath: store.state.game_install.game_path }) + await invoke("apply_launcher_pr", { pullRequest: pull_request, gameInstall: store.state.game_install }) .then((message) => { console.log(message); // Show user notification if mod install completed. @@ -72,7 +72,7 @@ export const pullRequestModule = { // Send notification telling the user to wait for the process to finish const notification = showNotification(`Installing mods PR ${pull_request.number}`, 'Please wait', 'info', 0); - await invoke("apply_mods_pr", { pullRequest: pull_request, gameInstallPath: store.state.game_install.game_path }) + await invoke("apply_mods_pr", { pullRequest: pull_request, gameInstall: store.state.game_install }) .then((message) => { // Show user notification if mod install completed. showNotification( -- cgit v1.2.3 From 37e5f80704234231cf42bceb6fbbdf3a93771a2e Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Thu, 3 Aug 2023 19:43:17 +0200 Subject: fix: Go over all folders during cleanup (#469) * fix: Go over all folders during cleanup of early return on error * fix: Remove now unused import --- src-tauri/src/repair_and_verify/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs index 6b9d3a98..8b68ce59 100644 --- a/src-tauri/src/repair_and_verify/mod.rs +++ b/src-tauri/src/repair_and_verify/mod.rs @@ -1,7 +1,6 @@ use crate::mod_management::{get_enabled_mods, rebuild_enabled_mods_json, set_mod_enabled_status}; /// Contains various functions to repair common issues and verifying installation use crate::{constants::CORE_MODS, GameInstall}; -use anyhow::anyhow; /// Verifies Titanfall2 game files #[tauri::command] @@ -59,7 +58,9 @@ pub fn clean_up_download_folder( download_dir_contents.for_each(|_| count += 1); if count > 0 && !force { - return Err(anyhow!("Folder not empty, not deleting")); + // Skip folder if not empty + log::warn!("Folder not empty, not deleting: {directory}"); + continue; } // Delete folder -- cgit v1.2.3 From efb193b517087d47f30f0542517c389bbfe5cde1 Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Thu, 3 Aug 2023 19:43:37 +0200 Subject: chore: Bump FlightCore version to 2.4.1 --- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index f4d1faab..6bcfbeb3 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -81,7 +81,7 @@ checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" [[package]] name = "app" -version = "2.4.0" +version = "2.4.1" dependencies = [ "anyhow", "async-recursion", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 6341d9a1..bb2cc525 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "app" -version = "2.4.0" +version = "2.4.1" description = "A Tauri App" authors = ["you"] license = "" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index b5b5b6f7..10610bbe 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "FlightCore", - "version": "2.4.0" + "version": "2.4.1" }, "tauri": { "allowlist": { -- cgit v1.2.3