fix: prevent duplicate downloads in album mode

This commit is contained in:
V1ck3s
2026-01-11 22:56:19 +01:00
committed by Vickes
parent 61a21b0e0c
commit 62246cc48f

View File

@@ -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);
}