feat(download): fill in the tracks a nearly complete album is missing
A grab that delivers nine of twelve tracks clears the completeness floor and is imported, and the other three were never looked for. On Soulseek that is the commonest way an album ends up almost right: one peer's folder lacks a track, or one file fails. After a successful import the manager now compares the tracks the files were aligned to (ImportResult.Matched, new) with the expected tracklist. When one to three are missing, and fewer than half, it searches for each one on its own, as the track's artist and title with the album kept for ranking. It grabs the first auto-acceptable copy that is not from the source that already failed to supply it, and is not a delegate, which would place it in its own library. The candidate is trimmed to the one file aligned to the track. The import uses the album's own request with ImportOptions.Only, which skips the completeness check and imports only a file aligned to the missing track, so it is tagged and placed as part of the album, and anything else the folder brought is left out. One attempt per track, and nothing here fails the download: the album is already imported, so a track that cannot be found is logged on the job and left. slskd accepts one-file folders for a request that expects one track, which the per-track search needs. Closes #276 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017HJiuc3ZZhxsPXz3ozTirT
This commit is contained in:
@@ -747,8 +747,9 @@ func (m *Manager) grab(
|
||||
var failed []Candidate
|
||||
|
||||
for {
|
||||
out := m.attemptGrab(ctx, dl, c, job)
|
||||
out := m.attemptGrab(ctx, dl, c, job, nil)
|
||||
if out.err == nil {
|
||||
m.fillIn(ctx, dl, c, out.imported, job)
|
||||
m.finishGrab(ctx, dl, out.item, out.imported, job)
|
||||
|
||||
return
|
||||
@@ -836,6 +837,7 @@ func (m *Manager) attemptGrab(
|
||||
dl Download,
|
||||
c Candidate,
|
||||
job *jobs.Handle,
|
||||
only []ExpectedTrack,
|
||||
) grabOutcome {
|
||||
// Who will move the bytes is decided before any slot is taken, so
|
||||
// the transfer waits in its own provider's queue rather than in a
|
||||
@@ -942,6 +944,7 @@ func (m *Manager) attemptGrab(
|
||||
|
||||
opts := m.importOptions()
|
||||
opts.WriteTags = true
|
||||
opts.Only = only
|
||||
|
||||
opts.LibraryRoot, err = m.library.LibraryPath(dl.LibraryID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user