You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
using Recyclarr.Cli.Console.Settings;
|
|
using Recyclarr.Cli.Pipelines.ReleaseProfile.PipelinePhases;
|
|
using Recyclarr.Config.Models;
|
|
|
|
namespace Recyclarr.Cli.Pipelines.ReleaseProfile;
|
|
|
|
public interface IReleaseProfilePipelinePhases
|
|
{
|
|
ReleaseProfileConfigPhase ConfigPhase { get; }
|
|
ReleaseProfileApiFetchPhase ApiFetchPhase { get; }
|
|
ReleaseProfileTransactionPhase TransactionPhase { get; }
|
|
Lazy<ReleaseProfilePreviewPhase> PreviewPhase { get; }
|
|
ReleaseProfileApiPersistencePhase ApiPersistencePhase { get; }
|
|
}
|
|
|
|
public class ReleaseProfileSyncPipeline(ILogger log, IReleaseProfilePipelinePhases phases) : ISyncPipeline
|
|
{
|
|
public async Task Execute(ISyncSettings settings, IServiceConfiguration config)
|
|
{
|
|
if (config is not SonarrConfiguration sonarrConfig)
|
|
{
|
|
log.Debug("Skipping release profile pipeline because {Instance} is not a Sonarr config",
|
|
config.InstanceName);
|
|
return;
|
|
}
|
|
|
|
var profiles = phases.ConfigPhase.Execute(sonarrConfig);
|
|
if (profiles is null)
|
|
{
|
|
log.Debug("No release profiles to process");
|
|
return;
|
|
}
|
|
|
|
var serviceData = await phases.ApiFetchPhase.Execute(config);
|
|
var transactions = phases.TransactionPhase.Execute(profiles, serviceData);
|
|
|
|
if (settings.Preview)
|
|
{
|
|
phases.PreviewPhase.Value.Execute(transactions);
|
|
return;
|
|
}
|
|
|
|
await phases.ApiPersistencePhase.Execute(config, transactions);
|
|
}
|
|
}
|