Repository navigation
Keep migrating a release until its files arrive - #7
Merged
Merged
Conversation
Album mode stranded most of each release. The recommended track is queued first and so normally finishes first, and migration ran once, at that moment: every sibling still transferring was skipped and never looked at again. The monitor then marked the track present and dropped it from its progress map, so nothing came back. A real run migrated 2 of 14 tracks and abandoned the other 11 in slskd's directory. MoveAlbumSiblings now reports how many files are still in flight, and the monitor retries each release every tick until that reaches zero. It drops migrated files from track.AlbumFiles so repeated calls are idempotent, and drops ones slskd has given up on so a failed transfer cannot hold a release open. Files still transferring are left alone, as before -- copying a partial file would put a truncated track in the library. The monitor's exit condition now also waits on outstanding releases, which is what makes the retry reachable. A release that stops making progress is abandoned on the same deadline a stalled track is, so a peer that goes away cannot keep the monitor running; its files are left in place rather than deleted. Progress is measured against the count the migrator last returned rather than against track.AlbumFiles, so the deadline depends only on the interface, not on how an implementation happens to keep score -- an earlier version read the field directly and a test with a different migrator abandoned a release that was actively downloading. Sibling migration moved out of MoveDownload, which now returns the directory the track landed in. Doing it there was wrong in principle: the work belongs where the retrying happens, not in a function that runs once. Directory cleanup moved with it, so a release directory is removed after the last sibling leaves rather than while siblings are still in it. errorState replaces the "Errored" literal, so code reacting to a failed transfer cannot drift from the code that labels one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes album mode stranding most of each release. Follow-up to #4.
The bug
The recommended track is queued first and so normally finishes first. Migration ran exactly once — at that moment — so every sibling still transferring was skipped. The monitor then set
track.Present = trueand deleted the track fromprogressMap, so nothing ever came back for them.From a real run:
11 of 14 tracks finished downloading into slskd's directory and stayed there.
moved=10on another release only worked because it happened to complete in order. I flagged this as a limitation when I wrote #4, but it fires on the common path, not an edge case.The fix
MoveAlbumSiblingsnow reports how many files are still in flight, and the monitor retries each release every tick until that reaches zero:track.AlbumFiles, so repeated calls are idempotent.Progress is measured against the count the migrator last returned rather than against
track.AlbumFiles. An earlier version read the field directly, and a test using a different migrator abandoned a release that was actively downloading — the deadline should depend on the interface, not on how an implementation keeps score.Refactor carried along
Sibling migration moved out of
MoveDownload, which now returns the directory the track landed in. Doing it there was wrong in principle: the work belongs where the retrying happens, not in a function that runs once. Directory cleanup moved with it, so a release directory is removed after the last sibling leaves rather than while siblings are still sitting in it.errorStatereplaces the"Errored"literal so code reacting to a failed transfer can't drift from the code that labels one.Testing
The end-to-end test drives
MonitorDownloadswith a release whose files arrive one pass at a time and asserts it doesn't return early. Mutation-checked by reverting the retry wiring — it fails withmigrator called 1 times; the monitor stopped before the release finishedand2 files were left behind, which is the reported symptom exactly.Also covers: a sibling that finishes on a later pass, migrated files not being retried, failed siblings not blocking completion, progress resetting the deadline, a stalled release being abandoned with its files left intact, and single-track downloads never being recorded for retry.
go build ./...,go vet ./src/...,go test ./src/...all pass.🤖 Generated with Claude Code