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::{
|
||||
collections::HashSet,
|
||||
path::{Path, PathBuf},
|
||||
@@ -21,6 +23,9 @@ struct LanSpreadState {
|
||||
games_folder: Arc<RwLock<String>>,
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
const FIRST_START_DONE_FILE: &str = ".softlan_first_start_done";
|
||||
|
||||
#[tauri::command]
|
||||
async fn request_games(state: tauri::State<'_, LanSpreadState>) -> tauri::Result<()> {
|
||||
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_start_bin = game_path.join("game_start.cmd");
|
||||
|
||||
let local_ready = local_install_is_ready(&game_path);
|
||||
if !local_ready && game_setup_bin.exists() {
|
||||
let first_start_done_file = game_path.join("local").join(FIRST_START_DONE_FILE);
|
||||
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(
|
||||
"cmd.exe",
|
||||
&format!(
|
||||
@@ -266,6 +279,13 @@ async fn run_game_windows(
|
||||
log::error!("failed to run game_setup.cmd");
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user