From 0eac6d298ca31fdf8e8b5c65d9c7e18b85cbcec7 Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Tue, 9 May 2023 23:53:48 +0200 Subject: Revert "refactor: Move `check_is_valid_game_path` to `main.rs` (#335)" This reverts commit 1ce900ca2d5cf91ae410c2ec918e1431aa15a677. --- src-tauri/src/github/pull_requests.rs | 2 +- src-tauri/src/lib.rs | 13 +++++++++++++ src-tauri/src/main.rs | 13 ------------- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src-tauri/src') diff --git a/src-tauri/src/github/pull_requests.rs b/src-tauri/src/github/pull_requests.rs index 9fb2e1cc..6c605424 100644 --- a/src-tauri/src/github/pull_requests.rs +++ b/src-tauri/src/github/pull_requests.rs @@ -1,7 +1,7 @@ use crate::github::release_notes::fetch_github_releases_api; -use crate::check_is_valid_game_path; use anyhow::anyhow; +use app::check_is_valid_game_path; use app::constants::{APP_USER_AGENT, PULLS_API_ENDPOINT_LAUNCHER, PULLS_API_ENDPOINT_MODS}; use serde::{Deserialize, Serialize}; use std::fs::File; diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index d4b9349f..e22801c5 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -141,6 +141,19 @@ pub fn find_game_install_location() -> Result { Err("Could not auto-detect game install location! Please enter it manually.".to_string()) } +/// Checks whether the provided path is a valid Titanfall2 gamepath by checking against a certain set of criteria +pub fn check_is_valid_game_path(game_install_path: &str) -> Result<(), String> { + let path_to_titanfall2_exe = format!("{game_install_path}/Titanfall2.exe"); + let is_correct_game_path = std::path::Path::new(&path_to_titanfall2_exe).exists(); + log::info!("Titanfall2.exe exists in path? {}", is_correct_game_path); + + // Exit early if wrong game path + if !is_correct_game_path { + return Err(format!("Incorrect game path \"{game_install_path}\"")); // Return error cause wrong game path + } + Ok(()) +} + /// Copied from `papa` source code and modified ///Extract N* zip file to target game path // fn extract(ctx: &Ctx, zip_file: File, target: &Path) -> Result<()> { diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 7dcb8f63..d3b58b67 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -301,19 +301,6 @@ async fn check_is_flightcore_outdated_caller() -> Result { check_is_flightcore_outdated().await } -/// Checks whether the provided path is a valid Titanfall2 gamepath by checking against a certain set of criteria -pub fn check_is_valid_game_path(game_install_path: &str) -> Result<(), String> { - let path_to_titanfall2_exe = format!("{game_install_path}/Titanfall2.exe"); - let is_correct_game_path = std::path::Path::new(&path_to_titanfall2_exe).exists(); - log::info!("Titanfall2.exe exists in path? {}", is_correct_game_path); - - // Exit early if wrong game path - if !is_correct_game_path { - return Err(format!("Incorrect game path \"{game_install_path}\"")); // Return error cause wrong game path - } - Ok(()) -} - /// Checks if is valid Titanfall2 install based on certain conditions #[tauri::command] async fn verify_install_location(game_path: String) -> bool { -- cgit v1.2.3