rtti_scan: restore write mode before unlink on replace failure (RTTI-SCAN-STAGE-CLEANUP) #798
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!798
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/rtti-scan-stage-cleanup"
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 successfully merged and closed
In
tools/rtti_scan.py,write_reportcreates a temporary file and appliespublished_mode(path)beforeos.replace. If the target is read-only (e.g. 0o444),os.removein theexcept BaseExceptionblock fails on Windows withPermissionError(WinError 5) ifos.replacefails, leaving the temporary file behind.Align with the repository standard:
except BaseException, restore write permissions (try: os.chmod(tmp, 0o600); except OSError: pass) before callingos.remove.PermissionErrorhandling and cleanup on replace failure.Tests pass (31/31 in
test_rtti_scan.py),scripts/check_no_game_data.pypasses cleanly.agent: yes
AI-assisted: yes
Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: on a failed replace the staged file gets 0o600 back before os.unlink, so a staged copy left read-only (the published mode on Windows) is still removed. Only the staging/permission lines change.
AI-assisted (Claude).
Reviewed a6ff1f4: the staged-report cleanup when os.replace fails. I ran the PR's
tests/test_rtti_scan.py: 31/31 pass on the PR tree, and on a main worktree with the PR's test file the new test fails (.rtti-*.tmpleft behind) while the other 30 pass, so it tests the fix. A probe with Windows-strict unlink reproduces the leak on main and its absence on the PR, with no change to the writable-destination path. compileall and check_no_game_data are clean. Findings: none. Optional follow-up outside this PR: the same pattern (staged file given the destination's read-only mode, then cleaned up without restoring write mode) appears in classify_carve.py:118, glb_writer.py:1078 and rsc8_audio.py:1966. AI-assisted review.Recommendation: Merge
Red/green: tests/test_rtti_scan.py fails 1 assertion on main (a read-only staged .rtti- file is left behind when replace fails under a strict remove) and passes with the PR (cloud run on main 7daa4a4).
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 7daa4a4a5 in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)
Verified by OreoFR
4a54aedcb+ PR heada6ff1f4d3python -I tests/test_rtti_scan.pyAI-assisted (Claude Code, Claude Opus 5.5).