fix: race endpoints for download metadata fetching

- GetTrackDownloadInfoAsync now uses RaceAllEndpointsAsync instead of TryWithFallbackAsync
- Prevents sequential fallback through all 10 endpoints on cancellation
- Eliminates cascade of 'task was canceled' warnings
- Consistent racing strategy across all download operations
This commit is contained in:
2026-02-07 12:49:43 -05:00
parent 2254616d32
commit 43bf71c390

View File

@@ -186,7 +186,8 @@ public class SquidWTFDownloadService : BaseDownloadService
{
return await QueueRequestAsync(async () =>
{
return await _fallbackHelper.TryWithFallbackAsync(async (baseUrl) =>
// Race all endpoints for fastest download info retrieval
return await _fallbackHelper.RaceAllEndpointsAsync(async (baseUrl, ct) =>
{
// Map quality settings to Tidal's quality levels
var quality = _squidwtfSettings.Quality?.ToUpperInvariant() switch
@@ -203,10 +204,10 @@ public class SquidWTFDownloadService : BaseDownloadService
Console.WriteLine($"%%%%%%%%%%%%%%%%%%% URL For downloads??: {url}");
var response = await _httpClient.GetAsync(url, cancellationToken);
var response = await _httpClient.GetAsync(url, ct);
response.EnsureSuccessStatusCode();
var json = await response.Content.ReadAsStringAsync(cancellationToken);
var json = await response.Content.ReadAsStringAsync(ct);
var doc = JsonDocument.Parse(json);
if (!doc.RootElement.TryGetProperty("data", out var data))
@@ -248,7 +249,7 @@ public class SquidWTFDownloadService : BaseDownloadService
MimeType = mimeType ?? "audio/flac",
AudioQuality = audioQuality ?? "LOSSLESS"
};
});
}, cancellationToken);
});
}