fix(peer): refresh settled install state after operations

The follow-up review found a few stale lifecycle edges around local game
transactions. Recovery could sweep active roots, post-operation refreshes
still re-ran full startup recovery, and the UI kept inferring local-only state
from downloaded and installed flags instead of the backend availability.

This updates the peer lifecycle so startup recovery skips active operations,
install/update/uninstall refresh only the affected game after the operation
guard is dropped, and path-changing game-directory updates are rejected while
operations are active. It also removes the dead UpdateGame command, drops the
unused manifest_hash write field while preserving old JSON reads, renames the
internal install-finished event, and carries availability through the DB,
peer summaries, Tauri refreshes, and the React model.

The included follow-up documents record the review source, implementation
decisions, and the remaining FOLLOW_UP_2.md work so later commits can stay
small instead of reopening the completed plan items.

Test Plan:
- git diff --check
- just fmt
- just clippy
- just test

Follow-up-Plan: FOLLOW_UP_PLAN.md
This commit is contained in:
2026-05-16 08:50:51 +02:00
parent fce34c7bd2
commit b5d20c1e72
22 changed files with 1389 additions and 131 deletions
+25 -1
View File
@@ -5,6 +5,10 @@ use std::{collections::HashMap, fmt, path::Path};
use serde::{Deserialize, Serialize};
pub const AVAILABILITY_READY: &str = "Ready";
pub const AVAILABILITY_DOWNLOADING: &str = "Downloading";
pub const AVAILABILITY_LOCAL_ONLY: &str = "LocalOnly";
/// Read version from version.ini file
/// # Errors
/// Returns error if file cannot be read or parsed
@@ -30,6 +34,10 @@ pub fn read_version_from_ini(game_dir: &Path) -> eyre::Result<Option<String>> {
}
}
fn default_availability() -> String {
AVAILABILITY_LOCAL_ONLY.to_string()
}
/// A game
#[derive(Clone, Serialize, Deserialize)]
pub struct Game {
@@ -57,6 +65,9 @@ pub struct Game {
/// only relevant for client (yeah... I know)
#[serde(default)]
pub installed: bool,
/// Backend-reported availability state for this game's local or peer summary.
#[serde(default = "default_availability")]
pub availability: String,
/// ETI game version from version.ini (YYYYMMDD format) (server)
pub eti_game_version: Option<String>,
/// Local game version from version.ini (YYYYMMDD format)
@@ -157,6 +168,7 @@ impl GameDB {
for game in self.games.values_mut() {
game.downloaded = false;
game.installed = false;
game.availability = AVAILABILITY_LOCAL_ONLY.to_string();
game.local_version = None;
}
}
@@ -207,7 +219,7 @@ impl fmt::Debug for GameFileDescription {
mod tests {
use serde_json::json;
use super::{Game, GameFileDescription};
use super::{AVAILABILITY_LOCAL_ONLY, Game, GameFileDescription};
#[test]
fn installed_defaults_to_false_when_missing() {
@@ -234,6 +246,7 @@ mod tests {
!game.installed,
"missing installed flag should default to false"
);
assert_eq!(game.availability, AVAILABILITY_LOCAL_ONLY);
}
#[test]
@@ -262,4 +275,15 @@ mod tests {
};
assert!(!other_game.is_version_ini());
}
#[test]
fn version_ini_predicate_accepts_windows_separators() {
let root = GameFileDescription {
game_id: "aoe2".to_string(),
relative_path: r"aoe2\version.ini".to_string(),
is_dir: false,
size: 8,
};
assert!(root.is_version_ini());
}
}