fix: address second code review findings

- Add context cancellation check between pagination pages in GetArtistReleaseGroups
  for responsive graceful shutdown during large discography fetches.
- Eliminate double DB query on cache hit by having GetCachedReleases return
  []ExternalRelease directly instead of just a count, avoiding a redundant
  second query in SyncArtistDiscography.
- Update cache_test.go to match new GetCachedReleases return type.
- Format main.go (pre-existing whitespace issue).
This commit is contained in:
2026-05-26 15:58:40 +03:00
parent 2baf586607
commit 582202bb86
5 changed files with 34 additions and 25 deletions

View File

@@ -60,6 +60,12 @@ func (c *MusicBrainzClient) GetArtistReleaseGroups(ctx context.Context, artistMB
if offset+len(parsed.ReleaseGroups) >= parsed.Count {
break
}
// Check context cancellation between pages for responsive shutdown.
if err := ctx.Err(); err != nil {
return nil, fmt.Errorf("fetch release groups for artist %s: %w", artistMBID, err)
}
offset += limit
}