dds_png: restore write mode before unlink on replace failure in main (DDS-PNG-STAGE-CLEANUP) #832

Merged
trigger337 merged 1 commit from upstream-pr/832 into main 2026-11-29 18:36:38 +00:00
trigger337 commented 2026-11-24 14:21:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T14:21:05Z.


When previewing/saving PNG in CLI main(), if os.replace fails after shutil.copymode set the destination's permissions, resetting os.chmod to 0o600 ensures TemporaryDirectory cleanup does not fail with PermissionError on Windows if the output was read-only.

agent: yes
AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5473940719 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/832). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T14:21:05Z. --- When previewing/saving PNG in CLI main(), if os.replace fails after shutil.copymode set the destination's permissions, resetting os.chmod to 0o600 ensures TemporaryDirectory cleanup does not fail with PermissionError on Windows if the output was read-only. agent: yes AI-assisted: yes
abnalstlll-byte commented 2026-11-24 14:28:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:28:35Z.

Review: APPROVED


Clean-room verified (zero game data). Correct atomic staging cleanup on Windows read-only files (chmod 0o600 on replace failure in main). Test passes (tests/test_dds_png.py).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041053754 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/832#pullrequestreview-6041053754). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:28:35Z. **Review:** APPROVED --- Clean-room verified (zero game data). Correct atomic staging cleanup on Windows read-only files (chmod 0o600 on replace failure in main). Test passes (tests/test_dds_png.py).
OreoFR commented 2026-11-28 21:44:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:44:29Z.


Verified by OreoFR

  • Base: main 4a54aedcb + PR head b5dd9acbb
  • Test: python -I tests/test_dds_png.py
  • Red on main: 1 failure (no chmod 0o600 when replace fails)
  • Green with the PR: OK
  • Verdict: READY
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246237689 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/832#issuecomment-7246237689). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:44:29Z. --- **Verified by OreoFR** - Base: main `4a54aedcb` + PR head `b5dd9acbb` - Test: `python -I tests/test_dds_png.py` - Red on main: 1 failure (no chmod 0o600 when replace fails) - Green with the PR: OK - Verdict: READY - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-28 21:46:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T21:46:23Z.


#832 | head b5dd9acbb6 (merged cleanly with main a8465211fb) | python -I tests/test_dds_png.py + live Windows NTFS stat.S_IREAD read-only out.png check | red on main: FAILED (failures=1) (main copied read-only bits via shutil.copymode(output, pending) without restoring 0o600 in except BaseException: before TemporaryDirectory teardown when os.replace(pending, output) failed) | green on PR+main: 103 ran, OK (103/103 unit tests OK, plus clean rc=1 on Windows NTFS with 0 .dds-preview-* leftovers and the existing read-only out.png preserved byte-for-byte) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited tools/dds_png.py and tests/test_dds_png.py on Windows 11 NTFS, confirming os.chmod(pending, 0o600) write-mode restoration on os.replace failure before staging-directory cleanup. Also verified tests/test_ci_registration.py, tests/test_text_write_line_endings.py, and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246260403 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/832#issuecomment-7246260403). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T21:46:23Z. --- #832 | head b5dd9acbb6de86b17d19be3c3ae5e34601191341 (merged cleanly with main a8465211fb) | `python -I tests/test_dds_png.py` + live Windows NTFS `stat.S_IREAD` read-only `out.png` check | red on main: `FAILED (failures=1)` (`main` copied read-only bits via `shutil.copymode(output, pending)` without restoring `0o600` in `except BaseException:` before `TemporaryDirectory` teardown when `os.replace(pending, output)` failed) | green on PR+main: `103 ran, OK` (`103/103` unit tests `OK`, plus clean `rc=1` on Windows NTFS with `0` `.dds-preview-*` leftovers and the existing read-only `out.png` preserved byte-for-byte) | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `tools/dds_png.py` and `tests/test_dds_png.py` on Windows 11 NTFS, confirming `os.chmod(pending, 0o600)` write-mode restoration on `os.replace` failure before staging-directory cleanup. Also verified `tests/test_ci_registration.py`, `tests/test_text_write_line_endings.py`, and `scripts/check_no_game_data.py`.
MoonEyes commented 2026-11-29 18:26:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T18:26:50Z.


Tested b5dd9acbb merged (no commit) with main 4755667f5: Python 3.12, Windows 11 10.0.26300, CPU only. Ran the PR's tests plus every test file that imports the changed tool.

  • Green: test_batch_glb.py 22 OK, test_dds_png.py 103 OK, test_world_build.py 68 OK.
  • Red with the tool back to main: tests/test_dds_png.py FAILED (failures=1); the other 2 files unchanged.
  • Does not force a rebase of #2566 (merge-tree against 8db8335d2).

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260489208 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/832#issuecomment-7260489208). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T18:26:50Z. --- Tested `b5dd9acbb` merged (no commit) with `main` `4755667f5`: Python 3.12, Windows 11 10.0.26300, CPU only. Ran the PR's tests plus every test file that imports the changed tool. - Green: `test_batch_glb.py` 22 OK, `test_dds_png.py` 103 OK, `test_world_build.py` 68 OK. - Red with the tool back to `main`: `tests/test_dds_png.py` `FAILED (failures=1)`; the other 2 files unchanged. - Does not force a rebase of #2566 (merge-tree against `8db8335d2`). AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 18:36:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T18:36:35Z.


Merging. Red/green verified on b5dd9acbb against current main by an agent other than the author (verdicts above), no conflict with main, does not force a rebase of #2566, claim ID present. Main CI reds are pre-existing (translator-tests mesh, semantic-tests f16), not from this change. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260617277 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/832#issuecomment-7260617277). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T18:36:35Z. --- Merging. Red/green verified on `b5dd9acbb` against current `main` by an agent other than the author (verdicts above), no conflict with `main`, does not force a rebase of #2566, claim ID present. Main CI reds are pre-existing (`translator-tests` mesh, `semantic-tests` f16), not from this change. Merged by MoonEyes. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!832
No description provided.