fix(download): try the next acceptable copy when a transfer fails
A failed transfer failed the whole download. On Soulseek the usual failure is one peer being offline or refusing, and a popular album has several other peers offering the same folder; the ranked list that names them was already held in m.results and nothing walked it. grab now loops: when a candidate's transfer fails, or delivers too little of the album to import, the next candidate is tried in its place, up to three in all. Three rules keep that honest: - Only a candidate auto-pick would itself have accepted is offered, so a second choice clears the same match, quality and guardrail gates as the first. - On Soulseek the failure is the peer's, so every folder that peer offered is skipped with it; elsewhere only the failed release is. - A candidate the user picked by hand does not fall back. They chose that copy, and quietly substituting another is a decision they did not make. The same change fixes auto-pick grabbing the wrong candidate. AutoPickVeto judges the best candidate inside the user's guardrails, but Start and Attempt then grabbed ranked[0] -- so when the overall best was over the size ceiling, the veto passed on the strength of the second and the first was downloaded anyway: the one copy the user had said not to take unattended. autoPick returns the candidate the veto actually judged. Closes #263 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017HJiuc3ZZhxsPXz3ozTirT
This commit is contained in:
1 parent
fc0121228e
commit
0a33b9d653
4 files changed
+507
-60
No files matched your search
@@ -735,6 +735,45 @@ func AutoPickVeto(
|
||||
return ""
|
||||
}
|
||||
|
||||
// autoAcceptable reports whether auto-pick may take this one candidate
|
||||
// without asking: the request is anchored to a tracklist, and the
|
||||
// candidate is inside the user's guardrails and clears the match and
|
||||
// quality bars. It is AutoPickVeto's test applied to a single
|
||||
// candidate, which is what falling back to a second choice needs.
|
||||
func autoAcceptable(dl Download, c Candidate, prefs AutoDownloadPrefs) bool {
|
||||
return dl.Anchored() &&
|
||||
len(dl.Expected) > 0 &&
|
||||
prefs.eligible(c, dl.runtimeMillis()) &&
|
||||
c.Match.Overall >= minMatch &&
|
||||
c.Quality.Overall >= minQuality
|
||||
}
|
||||
|
||||
// autoPick returns the candidate auto-pick takes: the best-ranked one
|
||||
// it may take at all.
|
||||
//
|
||||
// That is not `ranked[0]`. AutoPickVeto judges the best candidate
|
||||
// *inside* the guardrails, so when the overall best is outside them —
|
||||
// over the size ceiling, say — the veto passes on the strength of the
|
||||
// second, and grabbing the first would download exactly the copy the
|
||||
// user said not to take unattended.
|
||||
func autoPick(
|
||||
dl Download,
|
||||
ranked []Candidate,
|
||||
prefs AutoDownloadPrefs,
|
||||
) (Candidate, bool) {
|
||||
if AutoPickVeto(dl, ranked, prefs) != "" {
|
||||
return Candidate{}, false
|
||||
}
|
||||
|
||||
for _, c := range ranked {
|
||||
if autoAcceptable(dl, c, prefs) {
|
||||
return c, true
|
||||
}
|
||||
}
|
||||
|
||||
return Candidate{}, false
|
||||
}
|
||||
|
||||
// mergeMatched copies MatchedTo assignments from the audio-only slice
|
||||
// back onto the full file list.
|
||||
func mergeMatched(all, matched []CandidateFile) []CandidateFile {
|
||||
|
||||
Reference in new issue
Block a user