From c88b7ac1cce4d2d3b12d761bd66632f65a5a6e23 Mon Sep 17 00:00:00 2001 From: Maraco91 <43787609+Maraco91@users.noreply.github.com> Date: Tue, 24 Nov 2026 02:26:58 +0100 Subject: [PATCH] Game saves: an empty configuration id is the default, not every configuration's folder A provider's folder is the user's folder plus the configuration id as a file name. An empty id gave the user's folder itself, where the other configurations' folders are. Opening the provider converts containers of the old layout, which are folders without a `~` or a dot in their name, as a configuration's folder is: each was taken for one, an empty container was committed in its place and the folder was removed with every save in it. An empty id is now treated as no id (the default configuration). Co-Authored-By: Claude Fable 5.2 --- crates/victory-hle/src/modules/xgamesave.rs | 32 +++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/crates/victory-hle/src/modules/xgamesave.rs b/crates/victory-hle/src/modules/xgamesave.rs index 7282284..0d552e7 100644 --- a/crates/victory-hle/src/modules/xgamesave.rs +++ b/crates/victory-hle/src/modules/xgamesave.rs @@ -362,11 +362,14 @@ fn take(handle: *mut T) { impl Provider { /// The provider for the only user and `config` (the service - /// configuration id), under `saves`. + /// configuration id), under `saves`. An empty id names no + /// configuration, like none: as a folder name it would be the user's + /// folder itself, where the other configurations' folders are. fn open(saves: &Path, config: Option<&str>) -> Result { + let config = config.filter(|c| !c.is_empty()).unwrap_or("default"); let root = saves .join(format!("{:016X}", xuser::XUID)) - .join(file_name(config.unwrap_or("default"))); + .join(file_name(config)); std::fs::create_dir_all(&root).map_err(|_| NO_ACCESS)?; let _saves = saves_lock(); containers(&root); // converts old containers now @@ -1108,6 +1111,31 @@ mod tests { assert_eq!((v.number, v.display.as_str()), (1, "Chapter 1")); } + /// An empty configuration id names none. As a folder name it would be + /// the folder every configuration lives in, whose folders then look + /// like containers of the old layout and are converted away. + #[test] + fn an_empty_configuration_id_is_the_default_one() { + let saves = tempfile::tempdir().unwrap(); + let scid = Provider::open(saves.path(), Some("scid")).unwrap(); + assert_eq!(update(&scid.root, "one", &[("a", Some("kept"))]), S_OK); + let kept = Some(("one".into(), vec![("a".into(), "kept".into())])); + assert_eq!(state(&scid.root), kept); + + let empty = Provider::open(saves.path(), Some("")).unwrap(); + assert!(scid.root.is_dir(), "another configuration's saves are gone"); + assert_eq!(state(&scid.root), kept); + let default = Provider::open(saves.path(), None).unwrap(); + assert_eq!(empty.root, default.root); + + // Named configurations stay apart, from it and from each other. + assert_ne!(empty.root, scid.root); + assert_eq!(state(&empty.root), None); + let other = Provider::open(saves.path(), Some("other")).unwrap(); + assert_eq!(state(&other.root), None); + assert_eq!(state(&scid.root), kept); + } + #[test] fn saves_persist_across_providers() { let this: This = &OBJECT;