Skip to content

Reopening a Stem refuses one whose audio starts later than ours (#881) - #930

Merged
Skeyelab merged 1 commit into
mainfrom
fix/881-reopen-datastart
Oct 23, 2026
Merged

Skeyelab merged 1 commit into
mainfrom
fix/881-reopen-datastart

Conversation

@Skeyelab

Copy link
Copy Markdown
Member

Fixes #881. StemWriter.reopen assumed this writer's header size, so a Stem a DAW re-saved (its own chunk ahead of the audio) could be cut short and overwritten at the start by Repair's fill, a Marker rename or a channel rename.

  • reopen now throws when StemFile.inspect(url).dataStart != StemWriter.dataStart; nothing is written. Our own Stems, plain RIFF and RF64 alike, always start their audio at dataStart (the header doesn't depend on Info and RF64 promotion rewrites it in place); a test pins an RF64 reopen.
  • ChannelRenamer moved the file before it reopened it, so a refusal would have left a renamed Stem and an old Take.json. It now reopens first and moves last; a refused Stem keeps its name and bytes.
  • Marker rename: the outcome names the Stem that wasn't updated. CutOffTake.finishStem already had its own guard.
  • Red first: the new reopen test failed (it went ahead and altered the file), the channel-rename test failed (the Stem had been renamed), then the guard and the reorder. The Marker and RF64 tests passed on first run once the guard existed.
  • Not changed: the rejoin path in TakeSession (resuming a Stem our writer made during a live Take) writes at our offsets with no check; the reviewer rated it low risk and left it.

Checked only by tests, not on a Mac with a DAW. Not the real-time path. Code Reviewer: no blockers.

@Skeyelab
Skeyelab enabled auto-merge (squash) October 22, 2026 22:59
StemWriter.reopen assumed this writer's header size. For a Stem a DAW re-saved with
its own chunk ahead of the audio, Repair's fill, a Marker rename and a channel
rename wrote at the wrong offsets and could cut the file short. It now throws,
and nothing is written. ChannelRenamer reopens the Stem before it moves it, so a
refused Stem keeps its name.

Checked only by tests, not on a Mac with a DAW.

Assisted-by: Claude Code:claude-sonnet-5-5
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...RecorderKit/Sources/BroadcastWave/StemWriter.swift 87.50% 1 Missing ⚠️
...RecorderKit/Sources/Recording/ChannelRenamer.swift 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Skeyelab
Skeyelab merged commit 967af6f into main Oct 23, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Renaming a Marker or repairing a Take can damage a Stem a DAW re-saved (Mac)

1 participant