Skip to content

hashdict: stage --out so a write failure keeps the previous report - #9063

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

Grimkeh wants to merge 1 commit into
ItsNotRexed:mainfrom
Grimkeh:fix/hashdict-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_hashdict.py — OK

Made with Cursor

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

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

check3D commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Independent Linux review of c6ec1f00 merged cleanly onto main (867d922f) on Ubuntu 24.04, Python 3.12.16 (CPU only, no game files).

  • python -I tests/test_hashdict.py -v: 40/40 OK (2.95s).
  • Negative control (reverting tools/hashdict.py with new test kept): 1 error.
  • git diff --check and python -I scripts/check_no_game_data.py: clean.

Two non-blocking notes:

  1. If --out is a dangling symlink pointing into a missing directory, os.makedirs creates the symlink's parent (os.path.abspath(path)) rather than the resolved target's parent (os.path.dirname(destination)).
  2. Cross-PR conflict note: overlaps hunks in tools/hashdict.py with open PRs hashdict: guard --out against its inputs through report_paths.same_report_path (EGEN-HASHDICT-SHARED-PATH) #7839, hashdict: validate --out dir, --extra paths/min length, and u32 --lookup #4565, hashdict: a space or a typo in --archives is an error, not a silent partial harvest #7846, and hashdict: --lookup reads a dictionary JSON saved with a UTF-8 BOM #5768 (and tests/test_hashdict.py with hashdict: a space or a typo in --archives is an error, not a silent partial harvest #7846).

LGTM.

AI-assisted: yes.

@catminou4

Copy link
Copy Markdown

Tested on Apple M1 Max, macOS 27.2.1 arm64, Python 3.12.16: python -I tests/test_hashdict.py → 40 tests OK. No game files. AI-assisted (Devin).

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Independent Windows review (commit \c6ec1f00d00cd19e8b64f919ec74dcd376a54c10)

What changed:

  • \ ools/hashdict.py:
    • Stages --out\ JSON file writes through a temporary sibling file and commits atomically with
      eplace_retry.
    • Ensures unexpected mid-write interruptions (disk full, permissions) never corrupt existing dictionary output.
  • \ ests/test_hashdict.py:
    • Adds regression coverage verifying previous output is kept intact on failed write.

Verification:

  • Ran \python -I -m unittest discover -s tests -p test_hashdict.py: 40/40 tests pass (1 skipped).
  • Matches atomic write conventions across the tooling suite. Clean diff, zero game files.

Ready for merge.

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.

4 participants