feat: store launcher state outside game dirs
Move launcher-owned metadata from game roots into the configured peer state area. Peer identity, the local library index, install intent logs, and setup markers now live under app/CLI state instead of being written beside games. The Tauri shell passes its app data directory into the peer, and the peer CLI runs the same path through its explicit --state-dir. Add a dedicated pre-start migration phase for legacy files. It migrates the old global library index, per-game install intents, and the old first-start marker into app state, then deletes legacy files only after the replacement write succeeds. Normal scan, install, recovery, and transfer paths no longer read legacy state files. Rename the old first-start meaning to setup_done and only set it after launching game_setup.cmd. Start/setup scripts keep the shared argument shape, while server_start.cmd now uses cmd /k and a visible window so server logs stay open for inspection. While validating the Docker scenario matrix, make download terminal events come from the handler after local state refresh and operation cleanup. This makes download-finished/download-failed safe points for immediate follow-up CLI commands. Also update the multi-peer chunking scenario to use a sparse archive large enough to actually span multiple production chunks. Test Plan: - just fmt - just test - just frontend-test - just build - just clippy - git diff --check - python3 crates/lanspread-peer-cli/scripts/run_extended_scenarios.py Refs: local app-state migration discussion
This commit is contained in:
@@ -22,6 +22,7 @@ mod identity;
|
||||
mod install;
|
||||
mod library;
|
||||
mod local_games;
|
||||
mod migration;
|
||||
mod network;
|
||||
mod path_validation;
|
||||
mod peer;
|
||||
@@ -29,6 +30,7 @@ mod peer_db;
|
||||
mod remote_peer;
|
||||
mod services;
|
||||
mod startup;
|
||||
mod state_paths;
|
||||
#[cfg(test)]
|
||||
mod test_support;
|
||||
|
||||
@@ -42,6 +44,7 @@ pub use config::{CHUNK_SIZE, MAX_RETRY_COUNT};
|
||||
pub use error::PeerError;
|
||||
pub use install::{UnpackFuture, Unpacker};
|
||||
use lanspread_db::db::{Game, GameFileDescription};
|
||||
pub use migration::{MigrationReport, migrate_legacy_state};
|
||||
pub use peer_db::{
|
||||
MajorityValidationResult,
|
||||
PeerGameDB,
|
||||
@@ -56,7 +59,6 @@ use tokio::sync::{
|
||||
};
|
||||
use tokio_util::{sync::CancellationToken, task::TaskTracker};
|
||||
|
||||
pub use crate::startup::PeerRuntimeHandle;
|
||||
use crate::{
|
||||
context::Ctx,
|
||||
handlers::{
|
||||
@@ -73,7 +75,9 @@ use crate::{
|
||||
handle_uninstall_game_command,
|
||||
load_local_library,
|
||||
},
|
||||
state_paths::resolve_state_dir,
|
||||
};
|
||||
pub use crate::{startup::PeerRuntimeHandle, state_paths::setup_done_path};
|
||||
|
||||
// =============================================================================
|
||||
// Public API types
|
||||
@@ -300,12 +304,13 @@ pub fn start_peer_with_options(
|
||||
options: PeerStartOptions,
|
||||
) -> eyre::Result<PeerRuntimeHandle> {
|
||||
let PeerStartOptions { state_dir } = options;
|
||||
let state_dir = resolve_state_dir(state_dir.as_deref());
|
||||
let game_dir = game_dir.into();
|
||||
log::info!(
|
||||
"Starting peer system with game directory: {}",
|
||||
game_dir.display()
|
||||
);
|
||||
let peer_id = identity::load_or_create_peer_id(state_dir.as_deref())?;
|
||||
let peer_id = identity::load_or_create_peer_id(&state_dir)?;
|
||||
|
||||
let (tx_control, rx_control) = tokio::sync::mpsc::unbounded_channel();
|
||||
|
||||
@@ -316,6 +321,7 @@ pub fn start_peer_with_options(
|
||||
peer_game_db,
|
||||
peer_id,
|
||||
game_dir,
|
||||
state_dir,
|
||||
unpacker,
|
||||
catalog,
|
||||
))
|
||||
@@ -329,6 +335,7 @@ async fn run_peer(
|
||||
peer_game_db: Arc<RwLock<PeerGameDB>>,
|
||||
peer_id: String,
|
||||
game_dir: PathBuf,
|
||||
state_dir: PathBuf,
|
||||
unpacker: Arc<dyn Unpacker>,
|
||||
shutdown: CancellationToken,
|
||||
task_tracker: TaskTracker,
|
||||
@@ -338,6 +345,7 @@ async fn run_peer(
|
||||
peer_game_db,
|
||||
peer_id,
|
||||
game_dir,
|
||||
state_dir,
|
||||
unpacker,
|
||||
shutdown,
|
||||
task_tracker,
|
||||
|
||||
Reference in New Issue
Block a user