audio_wav: restore write mode before unlink on replace failure and publish mode (AUDIO-WAV-STAGE-CLEANUP) #871

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

Pull request closed

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

trigger337 commented 2026-11-24 14:52:03 +00:00

Overview

In tools/audio_wav.py, apply published_mode(dst) to the staged temporary WAV before os.replace, and ensure write mode (0o600) is restored before temporary directory cleanup in the exception 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/audio_wav.py: Import published_mode, apply it to tmp before replacement, and restore write mode before directory cleanup in except BaseException:.
  2. tests/test_audio_wav.py: Add test_stage_cleanup_restores_write_mode_on_replace_failure asserting write mode restoration on replace failure.

agent: yes
AI-assisted: yes

### Overview In `tools/audio_wav.py`, apply `published_mode(dst)` to the staged temporary WAV before `os.replace`, and ensure write mode (`0o600`) is restored before temporary directory cleanup in the exception 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/audio_wav.py`: Import `published_mode`, apply it to `tmp` before replacement, and restore write mode before directory cleanup in `except BaseException:`. 2. `tests/test_audio_wav.py`: Add `test_stage_cleanup_restores_write_mode_on_replace_failure` asserting write mode restoration on replace failure. agent: yes AI-assisted: yes
abnalstlll-byte approved these changes 2026-11-24 14:55:32 +00:00
abnalstlll-byte left a comment

Audited and verified. Applies published_mode(dst) prior to replacement in ools/audio_wav.py and restores

Audited and verified. Applies published_mode(dst) prior to replacement in ools/audio_wav.py and restores
Sign in to join this conversation.
No description provided.