[PR #992] [MERGED] xgameruntime_gamesave: undo a partly applied update instead of leaving it (RT-GAMESAVE-COMMIT-ROLLBACK) #1028

Closed
opened 2026-11-26 20:19:51 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/992
Author: @Snooozs
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: gamesave-commit-rollback


📝 Commits (1)

  • 34e6b29 xgameruntime_gamesave: undo a partly applied update instead of leaving it (RT-GAMESAVE-COMMIT-ROLLBACK)

📊 Changes

2 files changed (+185 additions, -13 deletions)

View changed files

📝 runtime/shims/xgameruntime_gamesave.cpp (+96 -13)
📝 runtime/test/xgameruntime_gamesave_test.cpp (+89 -0)

📄 Description

Claimed in the coordination issue as: RT-GAMESAVE-COMMIT-ROLLBACK (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137704829)

Depends on: none. #147 changes the quota loop of the same function; whichever lands second may need a small rebase.

What and why

commit() in runtime/shims/xgameruntime_gamesave.cpp replaced blobs one rename at a time. If a later rename failed (another process, such as a backup or antivirus tool, holds the blob open without FILE_SHARE_DELETE), XGameSaveSubmitUpdate returned E_GS_OUT_OF_LOCAL_STORAGE, but the earlier blobs were already new and a ~ file stayed. The container then held blobs of two different updates, against the file's own "a failed write leaves the container as it was".

  • Each op copies its blob to <blob>~b~ before changing it; a failed op undoes the applied ones, newest first, and the same error is returned.
  • Deletes run in the same ordered pass, so a failed write also undoes a delete. A delete that cannot be done now fails the update instead of being ignored.
  • Scratch names end in ~, which encode_name never produces and decode_name rejects, so enumeration and the quota do not see them.
  • A backup whose restore failed is kept, and later commits remove only backups they wrote. Temporaries of a commit that died midway are dropped.

Not covered: there is no journal. A process that dies midway leaves each blob old or new, as before. The path where the undo itself fails has no test. Names that differ only in case are unchanged.

Tested

Windows 10 Pro 22H2 (19045), VS 2022 RelWithDebInfo, ctest -R gamesave: xgameruntime_gamesave_test: 76 checks, 0 failures. The new test with main's shim: 76 checks, 5 failures. tests/test_saves.py (70 OK, 3 skipped) and tests/test_saves_import_args.py pass. check_no_game_data.py on both files: clean. Synthetic saves only.

GPUs tested: n/a

AI-assisted: yes. Claude Code (a Haiku 5.5 subagent found the bug and wrote the change, Claude Opus 5.5 reviewed and corrected it and reran the tests).

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator rule)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/992 **Author:** [@Snooozs](https://github.com/Snooozs) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `gamesave-commit-rollback` --- ### 📝 Commits (1) - [`34e6b29`](https://github.com/ubiquitarianism/leonida/commit/34e6b29682216bd878b4d5571a56b2cd19a82607) xgameruntime_gamesave: undo a partly applied update instead of leaving it (RT-GAMESAVE-COMMIT-ROLLBACK) ### 📊 Changes **2 files changed** (+185 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/xgameruntime_gamesave.cpp` (+96 -13) 📝 `runtime/test/xgameruntime_gamesave_test.cpp` (+89 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-GAMESAVE-COMMIT-ROLLBACK (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137704829) Depends on: none. #147 changes the quota loop of the same function; whichever lands second may need a small rebase. ### What and why `commit()` in `runtime/shims/xgameruntime_gamesave.cpp` replaced blobs one rename at a time. If a later rename failed (another process, such as a backup or antivirus tool, holds the blob open without `FILE_SHARE_DELETE`), `XGameSaveSubmitUpdate` returned `E_GS_OUT_OF_LOCAL_STORAGE`, but the earlier blobs were already new and a `~` file stayed. The container then held blobs of two different updates, against the file's own "a failed write leaves the container as it was". - Each op copies its blob to `<blob>~b~` before changing it; a failed op undoes the applied ones, newest first, and the same error is returned. - Deletes run in the same ordered pass, so a failed write also undoes a delete. A delete that cannot be done now fails the update instead of being ignored. - Scratch names end in `~`, which `encode_name` never produces and `decode_name` rejects, so enumeration and the quota do not see them. - A backup whose restore failed is kept, and later commits remove only backups they wrote. Temporaries of a commit that died midway are dropped. Not covered: there is no journal. A process that dies midway leaves each blob old or new, as before. The path where the undo itself fails has no test. Names that differ only in case are unchanged. ### Tested Windows 10 Pro 22H2 (19045), VS 2022 RelWithDebInfo, `ctest -R gamesave`: `xgameruntime_gamesave_test: 76 checks, 0 failures`. The new test with `main`'s shim: 76 checks, 5 failures. `tests/test_saves.py` (70 OK, 3 skipped) and `tests/test_saves_import_args.py` pass. `check_no_game_data.py` on both files: clean. Synthetic saves only. GPUs tested: n/a AI-assisted: yes. Claude Code (a Haiku 5.5 subagent found the bug and wrote the change, Claude Opus 5.5 reviewed and corrected it and reran the tests). ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator rule) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:51 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1028
No description provided.