[PR #798] rtti_scan: restore write mode before unlink on replace failure (RTTI-SCAN-STAGE-CLEANUP) #836

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

📋 Pull Request Information

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

Base: main ← Head: fix/rtti-scan-stage-cleanup


📝 Commits (1)

  • a6ff1f4 rtti_scan: restore write mode before unlink on replace failure (RTTI-SCAN-STAGE-CLEANUP)

📊 Changes

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

View changed files

📝 tests/test_rtti_scan.py (+23 -0)
📝 tools/rtti_scan.py (+4 -0)

📄 Description

In tools/rtti_scan.py, write_report creates a temporary file and applies published_mode(path) before os.replace. If the target is read-only (e.g. 0o444), os.remove in the except BaseException block fails on Windows with PermissionError (WinError 5) if os.replace fails, leaving the temporary file behind.

Align with the repository standard:

  1. In except BaseException, restore write permissions (try: os.chmod(tmp, 0o600); except OSError: pass) before calling os.remove.
  2. Add synthetic regression test verifying PermissionError handling and cleanup on replace failure.

Tests pass (31/31 in test_rtti_scan.py), scripts/check_no_game_data.py passes cleanly.

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/798 **Author:** [@trigger337](https://github.com/trigger337) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/rtti-scan-stage-cleanup` --- ### 📝 Commits (1) - [`a6ff1f4`](https://github.com/ubiquitarianism/leonida/commit/a6ff1f4d3265b18c1c26bdb1bfd63d109868bba2) rtti_scan: restore write mode before unlink on replace failure (RTTI-SCAN-STAGE-CLEANUP) ### 📊 Changes **2 files changed** (+27 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_rtti_scan.py` (+23 -0) 📝 `tools/rtti_scan.py` (+4 -0) </details> ### 📄 Description In `tools/rtti_scan.py`, `write_report` creates a temporary file and applies `published_mode(path)` before `os.replace`. If the target is read-only (e.g. 0o444), `os.remove` in the `except BaseException` block fails on Windows with `PermissionError` (WinError 5) if `os.replace` fails, leaving the temporary file behind. Align with the repository standard: 1. In `except BaseException`, restore write permissions (`try: os.chmod(tmp, 0o600); except OSError: pass`) before calling `os.remove`. 2. Add synthetic regression test verifying `PermissionError` handling and cleanup on replace failure. Tests pass (31/31 in `test_rtti_scan.py`), `scripts/check_no_game_data.py` passes cleanly. 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#836
No description provided.