Skip to content

Consolidate: never overwrite an earlier render - #470

Open
ItsAlphaNeon wants to merge 1 commit into
mainfrom
consolidate-no-overwrite
Open

ItsAlphaNeon wants to merge 1 commit into
mainfrom
consolidate-no-overwrite

Conversation

@ItsAlphaNeon

Copy link
Copy Markdown
Owner

Fixes #469.

What was wrong

Playlist Consolidate numbered its WAV by counting the files in the project's Rendered folder and adding one. A deleted render leaves a gap, and the count then lands on a file that is still there: with Consolidated 1.wav and Consolidated 3.wav, the new render picked 3 and replaced it, though a clip could still be playing it.

What changed

  • claim_consolidated (crates/os-app/src/playlist.rs) creates the first free Consolidated N.wav with File::create_new before the render starts, so it takes a gap and never an existing file. Because the create is exclusive, two renders into the same folder at once (two projects, two app instances) each get their own file.
  • The render writes into the claimed file. Render::Consolidate carries its path, and a render that fails (or writes nothing) removes it so the number stays free.
  • The export progress panel still shows the real file name.

This stays inside Consolidate: the shared export writer, Job and the pattern render are unchanged. The pattern render already avoided this through file_stem.

Tests

  • playlist_renders_play_hosted_plugins now consolidates into a Rendered folder holding Consolidated 1.wav and Consolidated 3.wav. It checks that the new file is Consolidated 2.wav and that both earlier files keep their bytes. On unchanged main this fails: file 3 is overwritten with the new WAV.
  • New consolidate_claims_a_free_file: it fills the gap, then the next free number, and 8 threads claiming at once each get a distinct file.
  • All 35 playlist tests pass on Windows. Clippy reports no warnings on the changed lines.

For the reviewer

  • If the app crashes mid-render, an empty Consolidated N.wav is left behind. Nothing references it, and later Consolidates skip it.
  • Thanks to the reporter (n0wsh), who also wrote a fix on their fork that claims the name at export-write time. This version claims it before the render instead, which keeps the change out of the shared export code.

🤖 Generated with Claude Code

Consolidate numbered its WAV by counting the files in the project's
Rendered folder. A deleted render leaves a gap, and the count then lands
on a file that is still there: with Consolidated 1.wav and 3.wav, the
new render replaced 3, which a clip could still be playing.

The file is now claimed before the render starts: the first free
Consolidated N.wav is created only if it does not exist yet (create_new),
which also keeps two renders into the same folder at once apart. A
render that fails removes its claimed file.

Fixes #469

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

[Bug]: Playlist Consolidate can overwrite an existing WAV when numbering has a gap

1 participant