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.3 KiB
46 lines
1.3 KiB
using Recyclarr.Cli.Console.Settings;
|
|
using Recyclarr.Config.Models;
|
|
|
|
namespace Recyclarr.Cli.Pipelines.Generic;
|
|
|
|
public class GenericSyncPipeline<TContext>(
|
|
ILogger log,
|
|
GenericPipelinePhases<TContext> phases,
|
|
IServiceConfiguration config
|
|
) : ISyncPipeline
|
|
where TContext : IPipelineContext, new()
|
|
{
|
|
public async Task Execute(ISyncSettings settings, CancellationToken ct)
|
|
{
|
|
var context = new TContext();
|
|
|
|
log.Debug("Executing Pipeline: {Pipeline}", context.PipelineDescription);
|
|
|
|
if (!context.SupportedServiceTypes.Contains(config.ServiceType))
|
|
{
|
|
log.Debug("Skipping this pipeline because it does not support service type {Service}", config.ServiceType);
|
|
return;
|
|
}
|
|
|
|
await phases.ConfigPhase.Execute(context, ct);
|
|
if (phases.LogPhase.LogConfigPhaseAndExitIfNeeded(context))
|
|
{
|
|
return;
|
|
}
|
|
|
|
await phases.ApiFetchPhase.Execute(context, ct);
|
|
phases.TransactionPhase.Execute(context);
|
|
|
|
phases.LogPhase.LogTransactionNotices(context);
|
|
|
|
if (settings.Preview)
|
|
{
|
|
phases.PreviewPhase.Execute(context);
|
|
return;
|
|
}
|
|
|
|
await phases.ApiPersistencePhase.Execute(context, ct);
|
|
phases.LogPhase.LogPersistenceResults(context);
|
|
}
|
|
}
|