Play game: first start done marker, local dir check
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
use std::fs::File;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
@@ -21,6 +23,9 @@ struct LanSpreadState {
|
|||||||
games_folder: Arc<RwLock<String>>,
|
games_folder: Arc<RwLock<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
const FIRST_START_DONE_FILE: &str = ".softlan_first_start_done";
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
async fn request_games(state: tauri::State<'_, LanSpreadState>) -> tauri::Result<()> {
|
async fn request_games(state: tauri::State<'_, LanSpreadState>) -> tauri::Result<()> {
|
||||||
log::debug!("request_games");
|
log::debug!("request_games");
|
||||||
@@ -250,8 +255,16 @@ async fn run_game_windows(
|
|||||||
let game_setup_bin = game_path.join("game_setup.cmd");
|
let game_setup_bin = game_path.join("game_setup.cmd");
|
||||||
let game_start_bin = game_path.join("game_start.cmd");
|
let game_start_bin = game_path.join("game_start.cmd");
|
||||||
|
|
||||||
let local_ready = local_install_is_ready(&game_path);
|
let first_start_done_file = game_path.join("local").join(FIRST_START_DONE_FILE);
|
||||||
if !local_ready && game_setup_bin.exists() {
|
if !first_start_done_file.exists() && game_setup_bin.exists() {
|
||||||
|
if !local_install_is_ready(&game_path) {
|
||||||
|
log::warn!(
|
||||||
|
"local install is missing or incomplete for {}; skipping game_setup",
|
||||||
|
game_path.display()
|
||||||
|
);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let result = run_as_admin(
|
let result = run_as_admin(
|
||||||
"cmd.exe",
|
"cmd.exe",
|
||||||
&format!(
|
&format!(
|
||||||
@@ -266,6 +279,13 @@ async fn run_game_windows(
|
|||||||
log::error!("failed to run game_setup.cmd");
|
log::error!("failed to run game_setup.cmd");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Err(e) = File::create(&first_start_done_file) {
|
||||||
|
log::error!(
|
||||||
|
"failed to create first-start marker {}: {e}",
|
||||||
|
first_start_done_file.display()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if game_start_bin.exists() {
|
if game_start_bin.exists() {
|
||||||
|
|||||||
Reference in New Issue
Block a user