Skip to content

gamedata_maps: stage --json so a write failure keeps the previous report - #8798

Open
Grimkeh wants to merge 1 commit into
ItsNotRexed:mainfrom
Grimkeh:fix/gamedata-maps-preserve-json
Open

Grimkeh wants to merge 1 commit into
ItsNotRexed:mainfrom
Grimkeh:fix/gamedata-maps-preserve-json

Conversation

@Grimkeh

@Grimkeh Grimkeh commented Nov 23, 2026

Copy link
Copy Markdown

Summary

Claim: #8504 (comment)

Synthetic; no game files. AI-assisted (Cursor / Composer).

Test plan

  • python3 -I -m unittest discover -s tests -p test_gamedata_maps.py — 26 OK

Made with Cursor

Publish through a temp file + replace so a mid-write OSError leaves any prior complete JSON intact.

Co-authored-by: Cursor <cursoragent@cursor.com>

@shyro29 shyro29 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested db1a76ef8 on Linux x86_64, CPython 3.14 (no game files): pass.

  • python -I tests/test_gamedata_maps.py at the head: OK; the same test file against main's tool: FAILED (errors=1) — red/green confirmed.
  • The staging follows the merged template (#2684, tools/bvh_index.py): stage beside the destination, published_mode for the bits, replace_retry to swap in, finally unlink of the staged name; the mid-write failure paths (serialization, interrupt, replace) keep the previous report because the destination is only touched by os.replace.
  • The os.close(os.open(destination, os.O_WRONLY)) probe keeps the direct writer's PermissionError for a read-only destination without truncating it, and the non-regular-destination branch (fifo/chardev) writes directly as before — both preserve old behaviour where staging cannot.
  • os.chmod skipped on Windows is fine: Windows chmod only toggles the read-only attribute, and skipping it means the staged file is never read-only, so the failed-replace cleanup cannot strand it (the concern #2684's cleanup comment records).
  • python -I scripts/check_no_game_data.py on the two changed files: clean. AI-assisted (Claude Code).

@garuspl

garuspl commented Nov 23, 2026

Copy link
Copy Markdown

Tested db1a76e on Windows 11 (CPU only, no GPU needed): pass

Windows 11 Pro, Python 3.14.7, no GPU or game files involved; pytest/numpy/Pillow pinned from tests/requirements.txt in a fresh venv. Method: PR head merged onto main 867d922, the PR's test files run with python -m pytest before and after the merge, plus python -m compileall -q on the changed files (clean).

  • tests/test_gamedata_maps.py: main 25 passed, 12 subtests passed; with the PR 26 passed, 12 subtests passed.

AI-assisted (Claude Code, Claude Opus 5.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants