From 43bf71c390040a2b6d21801a2c900c55fd6a7a55 Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Sat, 7 Feb 2026 12:49:43 -0500 Subject: [PATCH] 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 --- allstarr/Services/SquidWTF/SquidWTFDownloadService.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/allstarr/Services/SquidWTF/SquidWTFDownloadService.cs b/allstarr/Services/SquidWTF/SquidWTFDownloadService.cs index fe2e865..700929f 100644 --- a/allstarr/Services/SquidWTF/SquidWTFDownloadService.cs +++ b/allstarr/Services/SquidWTF/SquidWTFDownloadService.cs @@ -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); }); }