Launcher state folder: a durable run journal, an atomic final save, test seams out of release builds

未關閉
#246 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
cpp
領域
backend, testing

研究方向

Start with clean/installer/src/wg_core/record.h and install.cpp for the run journal, clean/wgshared/include/wg_state.h for settings replacement, and record.cpp plus the build targets for test seams. The issue specifies crash recovery, object identity, an editor-save interleaving test, and a release-binary check; completing and verifying all three areas requires coordinated changes across the installer, shared state code, and tests.

由索引模型根據 Issue 內容生成。

描述

area: launcher enhancement

Background

PR #224 moved the settings that the launcher and the in-game menu save into the game's state folder
(wronggpu-setup\settings.ini, clean/wgshared/include/wg_state.h). It made WrongGPU's files there recognisable by their
bytes, their name and the install's id, and made a failed install, repair or update take back only what that run made (a
run journal). Three smaller points remain.

1. The run journal is in memory only

clean/installer/src/wg_core/record.h (RunJournal) and install.cpp write down each create before it happens, but only
in memory:

  • A crash in the middle of an install loses the journal. A WrongGPU file the run created then has no record of being
    WrongGPU's, so it is kept and listed as if it were the player's (safe, but untidy).
  • An entry is a path, not the created object. If another program makes or replaces that path between the create and a
    rollback, the rollback deletes by path (a narrow interleaving).
  • RollbackCreated's list of what it kept is logged, not shown to the player in the result.

Proposed:

  • Write the journal to a file in the state folder, flushed before each create, and read it on the next run to finish or
    undo an interrupted one.
  • Keep each created file's identity (volume serial and file index) or hold it open, and delete only that object.
  • Return the kept list to the operation's result as a warning.

2. The settings save's last check is not atomic with the replace

wg_state.h UpdateSettings holds the file from the read to just before the move. It lets go, checks the file's
identity and last write once more (StillIdentity), then replaces it by path (MoveFileExW). An editor that saves in the
moment after the check and before the move can still lose its bytes. (A file made where none was is never replaced: that
move does not replace.)

Proposed: replace through a handle so that the check and the replace are one step. For example, rename the held file
aside through its own handle, move the new file in only where nothing is, and put the old one back if the move fails. Or
use ReplaceFileW with a backup name and compare the backup's identity afterwards. Add a test for an editor save between
the check and the move.

3. The C++ test seams are compiled into release builds

The environment-variable hooks (WRONGGPU_TEST_STOP_AT, WRONGGPU_TEST_FAIL_AT, WRONGGPU_TEST_CREATE_AT,
WRONGGPU_TEST_FAIL_AFTER_RESTORE) exist only in WRONGGPU_TESTING builds. The function-pointer seams they sit beside
are still in release builds:

  • wg_state.h TestFault() / Faulted();
  • record.cpp SetRestoreStepHook / RestoreStep and SetFaultHook / TestFault.

Nothing in a release build sets them, so they do nothing there, but they are code a release build does not need.

Proposed: compile them only into WRONGGPU_TESTING builds and the unit-test targets (an empty inline RestoreStep /
Faulted otherwise), with a release-build check that their names are not in the launcher.

Done when

  • An interrupted install leaves a journal that the next run uses, and a rollback deletes only the objects it created
    (unit tests: a crash after a create; a path replaced before the rollback).
  • A settings save cannot replace bytes an editor saved after WrongGPU's last check (unit test for that interleaving).
  • Release builds carry none of the test seams (checked on the built launcher).
主要語言
C++
星號
12
分支
2
平均合併
3 小時 10 分鐘
30 天內合併 PR
171

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

phantoslayer21/wronggpu 的其他 Issue

查看 phantoslayer21/wronggpu 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。