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.
25 lines
822 B
25 lines
822 B
using System.IO.Abstractions;
|
|
using Recyclarr.TrashGuide;
|
|
|
|
namespace Recyclarr.Config.Parsing.PostProcessing.ConfigMerging;
|
|
|
|
public class YamlIncludeResolver(IReadOnlyCollection<IIncludeProcessor> includeProcessors) : IYamlIncludeResolver
|
|
{
|
|
public IFileInfo GetIncludePath(IYamlInclude includeType, SupportedServices serviceType)
|
|
{
|
|
var processor = includeProcessors.FirstOrDefault(x => x.CanProcess(includeType));
|
|
if (processor is null)
|
|
{
|
|
throw new YamlIncludeException("Include type is not supported");
|
|
}
|
|
|
|
var yamlFile = processor.GetPathToConfig(includeType, serviceType);
|
|
if (!yamlFile.Exists)
|
|
{
|
|
throw new YamlIncludeException($"Included YAML file does not exist: {yamlFile.FullName}");
|
|
}
|
|
|
|
return yamlFile;
|
|
}
|
|
}
|