From 62246cc48fa9fceff54b42018ec3647c162b4293 Mon Sep 17 00:00:00 2001 From: V1ck3s Date: Sun, 11 Jan 2026 22:56:19 +0100 Subject: [PATCH] fix: prevent duplicate downloads in album mode --- .../Services/Common/BaseDownloadService.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/octo-fiesta/Services/Common/BaseDownloadService.cs b/octo-fiesta/Services/Common/BaseDownloadService.cs index b41aaa2..c37f309 100644 --- a/octo-fiesta/Services/Common/BaseDownloadService.cs +++ b/octo-fiesta/Services/Common/BaseDownloadService.cs @@ -290,6 +290,23 @@ public abstract class BaseDownloadService : IDownloadService continue; } + // Check if download is already in progress or recently completed + var songId = $"ext-{ProviderName}-{track.ExternalId}"; + if (ActiveDownloads.TryGetValue(songId, out var activeDownload)) + { + if (activeDownload.Status == DownloadStatus.InProgress) + { + Logger.LogDebug("Track {TrackId} download already in progress, skipping", track.ExternalId); + continue; + } + + if (activeDownload.Status == DownloadStatus.Completed) + { + Logger.LogDebug("Track {TrackId} already downloaded in this session, skipping", track.ExternalId); + continue; + } + } + Logger.LogInformation("Downloading track '{Title}' from album '{Album}'", track.Title, album.Title); await DownloadSongInternalAsync(ProviderName, track.ExternalId!, triggerAlbumDownload: false, CancellationToken.None); }