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

Closed
github-bot wants to merge 1 commit from gh-pr/813/head into gh-pr/813/base
Owner

@⁠trigger337 on GitHub · 2026-11-24 14:07 UTC · original
trigger337:fix/classify-carve-stage-cleanup → main · +16 −0 · 2 files · 1 commits · closed without merging

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

**@⁠trigger337** on GitHub · 2026-11-24 14:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/813) `trigger337:fix/classify-carve-stage-cleanup` → `main` · +16 −0 · 2 files · 1 commits · closed without merging 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:22:38 +00:00
github-bot closed this pull request 2026-11-26 09:22:38 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 19:50 UTC · original

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.

#720

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

**@⁠aslan2142** on GitHub · 2026-11-24 19:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/813#issuecomment-7142667680) 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://git.gtahub.st/github/ubiquitarianism--leonida/pulls/720 AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.