fix: resolve circular dependency in download service resolution by defining IConcreteDownloadService

This commit is contained in:
joshpatra committed 2026-07-08 10:07:02 -04:00
1 parent a60e921646
commit da53a3ccc6
5 files changed
+17 -10

No files matched your search

+4 -4
View File
@@ -588,10 +588,10 @@ builder.Services.AddSingleton<IConcreteMetadataService>(sp =>
sp.GetService<GenreEnrichmentService>()));
// 2. Concrete Download Services
builder.Services.AddSingleton<IDownloadService, DeezerDownloadService>();
builder.Services.AddSingleton<IDownloadService, QobuzDownloadService>();
builder.Services.AddSingleton<IDownloadService, AppleMusicDownloadService>();
builder.Services.AddSingleton<IDownloadService>(sp =>
builder.Services.AddSingleton<IConcreteDownloadService, DeezerDownloadService>();
builder.Services.AddSingleton<IConcreteDownloadService, QobuzDownloadService>();
builder.Services.AddSingleton<IConcreteDownloadService, AppleMusicDownloadService>();
builder.Services.AddSingleton<IConcreteDownloadService>(sp =>
new SquidWTFDownloadService(
sp.GetRequiredService<IHttpClientFactory>(),
sp.GetRequiredService<IConfiguration>(),
@@ -16,7 +16,7 @@ namespace allstarr.Services.Common;
/// Implements common download logic, tracking, and metadata writing.
/// Subclasses implement provider-specific download and authentication logic.
/// </summary>
public abstract class BaseDownloadService : IDownloadService
public abstract class BaseDownloadService : IConcreteDownloadService
{
protected readonly IConfiguration Configuration;
protected readonly ILocalLibraryService LocalLibraryService;
@@ -6,7 +6,7 @@ namespace allstarr.Services.Common;
public class MultiProviderDownloadService : IDownloadService
{
private readonly IEnumerable<IDownloadService> _allServices;
private readonly IEnumerable<IConcreteDownloadService> _allServices;
private readonly IMusicMetadataService _metadataService;
private readonly ProviderStatusManager _statusManager;
private readonly OdesliService _odesliService;
@@ -195,14 +195,14 @@ public class MultiProviderDownloadService : IDownloadService
public MultiProviderDownloadService(
IEnumerable<IDownloadService> services,
IEnumerable<IConcreteDownloadService> services,
IEnumerable<IConcreteMetadataService> metadataServices,
IMusicMetadataService metadataService,
ProviderStatusManager statusManager,
OdesliService odesliService,
ILogger<MultiProviderDownloadService> logger)
{
_allServices = services.Where(s => s.GetType() != typeof(MultiProviderDownloadService)).ToList();
_allServices = services.ToList();
_allMetadataServices = metadataServices.ToList();
_metadataService = metadataService;
_statusManager = statusManager;
+7
View File
@@ -64,3 +64,10 @@ public interface IDownloadService
/// </summary>
Task<bool> IsAvailableAsync();
}
/// <summary>
/// Marker interface to distinguish concrete download services from orchestrator services.
/// </summary>
public interface IConcreteDownloadService : IDownloadService
{
}
@@ -16,7 +16,7 @@ public class PlaylistSyncService
{
private readonly IConcreteMetadataService _deezerMetadataService;
private readonly IConcreteMetadataService _qobuzMetadataService;
private readonly IEnumerable<IDownloadService> _downloadServices;
private readonly IEnumerable<IConcreteDownloadService> _downloadServices;
private readonly IConfiguration _configuration;
private readonly SubsonicSettings _subsonicSettings;
private readonly ILogger<PlaylistSyncService> _logger;
@@ -36,7 +36,7 @@ public class PlaylistSyncService
public PlaylistSyncService(
IEnumerable<IConcreteMetadataService> metadataServices,
IEnumerable<IDownloadService> downloadServices,
IEnumerable<IConcreteDownloadService> downloadServices,
IConfiguration configuration,
IOptions<SubsonicSettings> subsonicSettings,
ILogger<PlaylistSyncService> logger)