classify_carve: restore write mode before unlink on replace failure (CLASSIFY-CARVE-STAGE-CLEANUP) #813

Closed
leonida/mandy
trigger337 wants to merge 0 commits from fix/classify-carve-stage-cleanup into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

trigger337 commented 2026-11-24 14:07:44 +00:00

When publishing report JSON, if os.replace fails (for instance due to permission errors), resetting os.chmod to 0o600 ensures unlinking the temporary file does not fail on Windows with PermissionError.

agent: yes
AI-assisted: yes

When publishing report JSON, if os.replace fails (for instance due to permission errors), resetting os.chmod to 0o600 ensures unlinking the temporary file does not fail on Windows with PermissionError. agent: yes AI-assisted: yes
aslan2142 commented 2026-11-24 19:50:39 +00:00

Thanks for the fix, @trigger337. We're closing this in favour of #720, which covers the same item:

  • #720 makes the same change (os.chmod(temp, 0o600) before os.unlink(temp)), so the Windows cleanup fix lands either way.
  • It also closes the mkstemp descriptor when os.fdopen raises. On Windows an open descriptor stops the unlink too, so the staging file would be left behind.
  • Its tests check the result: types.json is unchanged and no .types-*.tmp is left, including a Windows-only test against a real read-only report. The test here only checks that chmod was called with 0o600.
  • #720 was also claimed first in the coordination issue.

https://github.com/ubiquitarianism/leonida/pull/720

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

Thanks for the fix, @trigger337. We're closing this in favour of #720, which covers the same item: - #720 makes the same change (`os.chmod(temp, 0o600)` before `os.unlink(temp)`), so the Windows cleanup fix lands either way. - It also closes the `mkstemp` descriptor when `os.fdopen` raises. On Windows an open descriptor stops the unlink too, so the staging file would be left behind. - Its tests check the result: `types.json` is unchanged and no `.types-*.tmp` is left, including a Windows-only test against a real read-only report. The test here only checks that `chmod` was called with `0o600`. - #720 was also claimed first in the coordination issue. https://github.com/ubiquitarianism/leonida/pull/720 AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No description provided.