[PR #845] native_pso_hashes: restore write mode before unlink on replace failure and publish mode (NATIVE-PSO-HASHES-STAGE-CLEANUP) #883

Open
opened 2026-11-26 20:19:22 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/845
Author: @trigger337
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/native-pso-hashes-stage-cleanup


📝 Commits (1)

  • 333716f native_pso_hashes: restore write mode before unlink on replace failure and publish mode (NATIVE-PSO-HASHES-STAGE-CLEANUP)

📊 Changes

2 files changed (+21 additions, -0 deletions)

View changed files

📝 tests/test_native_pso_hashes.py (+15 -0)
📝 tools/native_pso_hashes.py (+6 -0)

📄 Description

Overview

In tools/native_pso_hashes.py, apply published_mode(out) before atomic replacement, and ensure write mode (0o600) is restored before unlinking in the finally block if replacement fails.

On Windows, unlinking a read-only staged file or cleaning up on os.replace failure causes a PermissionError [WinError 5], leaving stranded temporary files behind and masking underlying exceptions.

Changes

  1. tools/native_pso_hashes.py: Import published_mode, apply it before os.replace, and restore write permissions before unlinking.
  2. tests/test_native_pso_hashes.py: Add test_stage_cleanup_restores_write_mode_on_replace_failure asserting write permissions are restored on replace failure.

agent: yes
AI-assisted: yes


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/845 **Author:** [@trigger337](https://github.com/trigger337) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/native-pso-hashes-stage-cleanup` --- ### 📝 Commits (1) - [`333716f`](https://github.com/ubiquitarianism/leonida/commit/333716f1e387f311a41ec1d547c5220924911e96) native_pso_hashes: restore write mode before unlink on replace failure and publish mode (NATIVE-PSO-HASHES-STAGE-CLEANUP) ### 📊 Changes **2 files changed** (+21 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_native_pso_hashes.py` (+15 -0) 📝 `tools/native_pso_hashes.py` (+6 -0) </details> ### 📄 Description ### Overview In `tools/native_pso_hashes.py`, apply `published_mode(out)` before atomic replacement, and ensure write mode (`0o600`) is restored before unlinking in the finally block if replacement fails. On Windows, unlinking a read-only staged file or cleaning up on `os.replace` failure causes a `PermissionError` [WinError 5], leaving stranded temporary files behind and masking underlying exceptions. ### Changes 1. `tools/native_pso_hashes.py`: Import `published_mode`, apply it before `os.replace`, and restore write permissions before unlinking. 2. `tests/test_native_pso_hashes.py`: Add `test_stage_cleanup_restores_write_mode_on_replace_failure` asserting write permissions are restored on replace failure. agent: yes AI-assisted: yes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#883
No description provided.