mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:45:54 +01:00
[PR #1760] rpf9_carve: publish index.json atomically and guard stream outputs aliasing input archive (RPF9-CARVE-ATOMIC-INDEX-AND-INPUT-GUARD) #1773
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1773
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1760
Author: @kirigayakazima
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rpf9-carve-atomic-index-and-input-guard📝 Commits (1)
0f83828rpf9_carve: publish index.json atomically and guard stream outputs aliasing input archive📊 Changes
2 files changed (+126 additions, -3 deletions)
View changed files
📝
tests/test_rpf9_carve_errors.py(+89 -0)📝
tools/rpf9_carve.py(+37 -3)📄 Description
Claimed in the coordination issue as: RPF9-CARVE-ATOMIC-INDEX-AND-INPUT-GUARD https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161163878
What and why
Hardens
tools/rpf9_carve.pyacross three edge cases:.bin/.bk2outputs aliasing the input archive: Before opening<out>/<offset>.bk2or<out>/<offset>.bin, checksame_report_path(out_file, a.archive)(matching the existingindex.jsoncheck) so an input archive named like a carved output insideout_dircannot be truncated on POSIX or fail with a confusing write error on Windows.index.jsonpublishing with Windows read-only cleanup: Replace directopen(index_path, "w", ...)with_write_index_atomic(writes LF-terminated JSON ending in\nto a temporary file in the destination directory, appliespublished_mode(dest), publishes viareplace_retry, and restores0o600before unlinking on failure so Windows read-only targets do not strand.rpf9_carve-*.tmpfiles or leave truncatedindex.jsonbehind).donein the 2,000-row progress print frombaseinstead ofa.start or 0so progress reflects the scanned data span when--startis omitted.Adds 4 synthetic regression tests in
tests/test_rpf9_carve_errors.py.Tested
Windows 11 x64 (
10.0.26100), Python3.14.7, CPU only, synthetic archives only (no game files). Commit0f83828fa789f7efe2162317e8438d0cfd6e8c82.python -I tests/test_rpf9_carve_errors.py -v:main(bcaa13da) with all 7 tests: 4 failures (new tests fail on.bin/.bk2aliasing, truncatedindex.jsonon mid-write failure, and missing trailing newline);python -I tests/test_rpf9_carve.py -v: 17 tests, OK.python -I tests/test_ci_registration.py: 16 tests, OK.python -I tests/test_text_write_line_endings.py: 3 tests, OK.python -I scripts/check_no_game_data.py tools/rpf9_carve.py tests/test_rpf9_carve_errors.py,python -m compileall -q tools tests,git diff --check: exit0.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.