From a24a21bff51f86f0de25572675534d3951c18ae6 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Sun, 8 Nov 2026 08:54:30 -0500 Subject: [PATCH] Write make_game.py's state.json whole or not at all. A write cut by a full disk or by Cancel ending the build left a state.json that loads as {}: the launcher then took the built game for none, showed the first run and needed the dump again for a rebuild. It is now written to a temporary file and moved into place. Co-Authored-By: Claude Opus 5.5 --- tools/make_game.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/make_game.py b/tools/make_game.py index 9d72fad2..7a297436 100644 --- a/tools/make_game.py +++ b/tools/make_game.py @@ -1108,8 +1108,12 @@ def main(): state_lock = threading.Lock() # the RomFS step records itself from its own thread def save(): + # whole or not at all: a cut write (a full disk, Cancel ending the process) would leave a state.json that + # loads as {}, and the launcher would take the built game for none and ask for the dump again with state_lock: - state_path.write_text(json.dumps(state, indent=1), encoding='utf-8') + tmp = state_path.with_name(state_path.name + '.tmp') + tmp.write_text(json.dumps(state, indent=1), encoding='utf-8') + os.replace(tmp, state_path) def run(name): t = time.time()