anim_move: restore write mode before unlink on replace failure and publish mode on Windows (ANIM-MOVE-STAGE-CLEANUP) #777
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/777"
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?
Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T13:42:09Z.
In
tools/anim_move.py,_write_json_atomiccreates a temporary file and previously skipped applyingpublished_modeon Windows becauseos.unlinkin thefinallyblock fails withPermissionError(WinError 5) ifreplace_retryfails on read-only destinations.Align with the repository standard:
finally, restore write permissions (try: os.chmod(staged.name, 0o600); except OSError: pass) before unlinking.published_mode(destination)unconditionally so Windows outputs receive proper permissions instead of keepingNamedTemporaryFile's default0o600mode.PermissionErrorhandling and Windowspublished_modeapplication.Tests pass (12/12 in
test_anim_move.py),scripts/check_no_game_data.pypasses cleanly.agent: yes
AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T04:01:42Z.
Review: APPROVED
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; and the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change.
AI-assisted (Claude).
Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T20:05:13Z.
Reviewed
efe0568: I ranpython3 -I tests/test_anim_move.pyon Linux (12/12 on the PR; on main with this PR's test file only the os.name="nt" mode test fails),check_no_game_data.py(clean), and a probe againstorigin/main. The cleanup change is correct where reachable: with writable destination +published_modeforced to 0o444 + failing replace, main strands a read-only staged file and masks the replace error, this branch removes it and re-raises. Buttest_publish_cleans_up_staged_file_when_replace_fails_even_if_readonlynever reaches that code as a normal user - the 0o444 destination raises at the pre-stageos.open(destination, os.O_WRONLY)check (line 589) before staging, so it also passes on main with the fix reverted (probe:staged file created: Falseon both trees). Please forcepublished_modeon a writable destination (or patch the check) so the test fails on main, and assert the published mode in the os.name="nt" test rather thanlen(chmod_calls) > 0, which the newfinally:chmod on the renamed-away staged name also satisfies. No product regression found. AI-assisted review.Recommendation: Fix first
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-26T06:57:23Z.
Confirming @PierreEbele's finding, and why my approval missed it. I ran the PR's test file against main's tool, and the cleanup test (
..._replace_fails_even_if_readonly) did fail there. But this workspace runs as root, and root opens a 0o444 file for writing anyway, so it gets past the pre-stageos.open(destination, os.O_WRONLY)check and into the staged-file cleanup. As a normal user on Linux, and on Windows where the read-only attribute is honoured, that check refuses the destination before anything is staged, so the test passes on main too and doesn't pin the fix. The code change is still right where it can be reached. The test needs a writable destination with the published mode forced to 0o444 (as the review suggests) to fail on main for everyone. AI-assisted (Claude).Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T11:04:14Z.
Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main
3ca0707: no new failure, Linux / Python 3.13.AI-assisted (Claude Code, Claude Opus 5.5)