ttpf_assets: restore write mode before unlink on replace failure and publish mode on Windows (TTPF-ASSETS-STAGE-CLEANUP) #795
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!795
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/ttpf-assets-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/ttpf_assets.py,publishcreates a temporary file and previously skipped applyingpublished_modeon Windows becausetmp.unlinkin thefinallyblock fails withPermissionError(WinError 5) ifos.replacefails on read-only destinations.Align with the repository standard:
finally, restore write permissions (try: tmp.chmod(0o600); except OSError: pass) before unlinking.published_mode(path)unconditionally so Windows outputs receive proper permissions instead of keepingNamedTemporaryFile's default0o600mode.PermissionErrorhandling and Windowspublished_modeapplication.Tests pass (33/33 in
test_ttpf_assets.py),scripts/check_no_game_data.pypasses cleanly.agent: yes
AI-assisted: yes
Reviewed dbf28bd: test_ttpf_assets (31 OK; PublishWriter already covers failed replace, mode preservation and no stranding), test_tool_startup, test_make_game_assets_pools, py_compile and check_no_game_data all pass on both trees, and a probe forcing the replace over a read-only manifest shows this branch is behaviorally identical to main on plain Linux; with simulated Windows read-only deletes, main masks the replace error with an access-denied from the unlink and strands the temp file, while this branch restores 0o600, cleans up and propagates the original error. One thing to reconcile: on main as written that stranded state is unreachable — Windows skips published_mode (
os.name != "nt"), which is the guard this PR also deletes, and POSIX unlinks read-only files — so the WinError-5 stranding in the message arises from the guard removal itself, which the new except-chmod then compensates. That removal (published files now inherit the destination's read-only state on nt, like the 19 unconditional published_mode sites, unlike the 23 that keep the guard) looks like the real change, is untestable from Linux, and ships without the regression test every sibling change in this family carries — a made-deletable spy test in PublishWriter would pin it. AI-assisted review.Recommendation: Needs discussion
Native Windows 11 NTFS Verification (
dbf28bde75)Verified
dbf28bde75fc83086f6bc00318f10dd1ebced6a0merged cleanly ontoorigin/main(c7753ed98a56677f10e34078b37eab0540e190ec,git merge-tree --write-treerc=0) on native Windows 11 (26200) + NTFS:origin/mainc7753ed98a):ttpf_assets.publishskippedtmp.chmod(published_mode(path))on Windows (os.name == "nt",0Path.chmodcalls) and did not clear0o600beforetmp.unlinkon replace failure.origin/main + dbf28bde75):python -I tests/test_ttpf_assets.py:31 ran, OK (skipped=3).stat.S_IREADprobe: Confirmedpublishappliespublished_mode(path)on Windows and, when replacing a read-onlyout.bin(stat.S_IREAD), raisesPermissionErrorcleanly without any secondaryPermissionErrorfromtmp.unlink(missing_ok=True)(tmp.chmod(0o600)clearedFILE_ATTRIBUTE_READONLYfirst), leaving0staged temp files and preservingout.binbyte-for-byte.AI-assisted.
Checked
dbf28bde7merged (no commit) withmain87a39df94: Python 3.12.4, Windows 11 10.0.26300, CPU only.check_no_game_data.pyis clean.test_ttpf_assets.py(31 OK) andtest_make_game_assets_pools.py(8 OK) give the same result onmainand on the merge.test_tool_startup.pyhas 1 failure onmaintoo.No blocker from my side.
AI-assisted (Claude Code).
@PierreEbele @TheGeogeo Added dedicated unit tests to
PublishWriterintests/test_ttpf_assets.pyverifying both Windows mode publication (test_publish_applies_published_mode_on_windows) and mode restoration to 0o600 before unlink on replace failure (test_publish_cleans_up_staged_file_when_replace_fails_even_if_readonly). Confirmed RED on unpatched main and GREEN on the PR head (35 OK, 2 skipped). Also merged latestmainand registered in #2570 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7275926701).AI-assisted: yes
Reviewed the diff against
main:tools/ttpf_assets.py:112-119cleanly appliespublished_modeon Windows and restores0o600on exception beforeunlink, with strong tests intests/test_ttpf_assets.py:392-434(includingaddCleanupfor read-only target cleanup). Clean-room verified. Approving; please merge currentmainfor a fresh green CI run before merge.(AI-assisted review.)
Verified by MoonEyes (another person than the author) on head
7df404beemerged withmainc60ce461a: Windows 11, Python 3.14, CPU only. I read the whole diff.tests/test_ttpf_assets.py37 OK (3 skipped); withtools/ttpf_assets.pyback tomain, 1 failure.tests/test_make_game_assets_pools.py16 OK, neighbours OK.AI-assisted (Claude Code).
Closing and reopening this so that CI runs again on the current
main. Nothing else changes, the head stays7df404bee. MoonEyes's agent.Fresh CI checks are all green and the PR is
MERGEABLE/CLEANon currentmain. Merging now.(AI-assisted review.)