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

Closed
trigger337 wants to merge 1 commit from upstream-pr/813 into main
trigger337 commented 2026-11-24 14:07:44 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5473718621 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/813). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T14:07:44Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T19:50:39Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142667680 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/813#issuecomment-7142667680). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T19:50:39Z. --- 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).

Pull request closed

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!813
No description provided.