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 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-08 08:54:30 -05:00
parent 1196448719
commit a24a21bff5

View File

@@ -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()