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.
recyclarr/src/Recyclarr.Cli/Pipelines/Generic/GenericSyncPipeline.cs

40 lines
1.2 KiB

using Recyclarr.Cli.Console.Settings;
using Recyclarr.Config.Models;
namespace Recyclarr.Cli.Pipelines.Generic;
public class GenericSyncPipeline<TContext>(ILogger log, GenericPipelinePhases<TContext> phases) : ISyncPipeline
where TContext : IPipelineContext, new()
{
public async Task Execute(ISyncSettings settings, IServiceConfiguration config)
{
var context = new TContext();
if (!context.SupportedServiceTypes.Contains(config.ServiceType))
{
log.Debug("Skipping {Description} because it does not support service type {Service}",
context.PipelineDescription, config.ServiceType);
return;
}
await phases.ConfigPhase.Execute(context, config);
if (phases.LogPhase.LogConfigPhaseAndExitIfNeeded(context))
{
return;
}
await phases.ApiFetchPhase.Execute(context, config);
phases.TransactionPhase.Execute(context, config);
phases.LogPhase.LogTransactionNotices(context);
if (settings.Preview)
{
phases.PreviewPhase.Execute(context);
return;
}
await phases.ApiPersistencePhase.Execute(context, config);
phases.LogPhase.LogPersistenceResults(context);
}
}