#1589

hashdict.py: refuse an --out that names one of its inputs

Openundeadhuman37wants to merge intofrom

Claimed in the coordination issue: https://github.com/ItsNotRexed/Leonida/issues/1548#issuecomment-7079131590 (new BUILD item)

What and why

tools/hashdict.py writes the dictionary after the whole harvest. If --out names one of its own inputs (an --extra file, or a carve folder's <archive>/index.json), that input was silently replaced with the dictionary.

Now, when --out already exists, it is compared with those inputs before scanning starts. A match exits 2 with one ERROR line and leaves the file alone. os.path.samefile also catches case-only differences on Windows and on macOS's default case-insensitive volume.

Tests

  • New OutputPathTest.test_out_naming_an_input_is_refused_and_left_alone: synthetic carve folder plus an --extra file; both collisions are refused and the bytes stay the same. It fails without the fix and passes with it.
  • python -I tests/test_hashdict.py: 26 tests OK
  • python -m compileall -q make_game.py tools tests and python -I make_game.py --help OK

Tested on Windows 11 (RTX 4070 SUPER; no GPU needed for this change). No game files used.

AI-assisted (Claude Code).

🤖 Generated with Claude Code