diff --git a/src/FilterLists.Agent/Infrastructure/DependencyInjection/ServiceCollectionExtensions.cs b/src/FilterLists.Agent/Infrastructure/DependencyInjection/ServiceCollectionExtensions.cs index 77eb19511..013dd5204 100644 --- a/src/FilterLists.Agent/Infrastructure/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/FilterLists.Agent/Infrastructure/DependencyInjection/ServiceCollectionExtensions.cs @@ -4,10 +4,10 @@ using CommandLine; using FilterLists.Agent.AppSettings; using FilterLists.Agent.Core; -using FilterLists.Agent.Core.List; +using FilterLists.Agent.Infrastructure.Disk; using FilterLists.Agent.Infrastructure.FilterListsApi; using FilterLists.Agent.Infrastructure.GitHub; -using LibGit2Sharp; +using FilterLists.Agent.Infrastructure.Web; using MediatR; using Microsoft.ApplicationInsights; using Microsoft.Extensions.Configuration; @@ -89,23 +89,5 @@ private static void AddUrlRepository(this IServiceCollection services) b.OrResult(r => r.StatusCode == HttpStatusCode.TooManyRequests) .WaitAndRetryAsync(5, i => i * TimeSpan.FromSeconds(3))); } - - private static void AddListRepository(this IServiceCollection services) - { - services.AddHttpClient().AddTransientHttpErrorPolicy(b => - b.OrResult(r => r.StatusCode == HttpStatusCode.TooManyRequests) - .WaitAndRetryAsync(5, i => i * TimeSpan.FromSeconds(3))); - } - - private static void AddArchiveRepository(this IServiceCollection services) - { - services.AddTransient(s => - { - var archiveSettings = s.GetService>().Value; - if (!Repository.IsValid(archiveSettings.RepositoryDirectory)) - Repository.Init(archiveSettings.RepositoryDirectory); - return new Repository(archiveSettings.RepositoryDirectory); - }); - } } } \ No newline at end of file diff --git a/src/FilterLists.Agent/Infrastructure/Disk/ServiceCollectionExtensions.cs b/src/FilterLists.Agent/Infrastructure/Disk/ServiceCollectionExtensions.cs new file mode 100644 index 000000000..77e49d2f5 --- /dev/null +++ b/src/FilterLists.Agent/Infrastructure/Disk/ServiceCollectionExtensions.cs @@ -0,0 +1,21 @@ +using FilterLists.Agent.AppSettings; +using LibGit2Sharp; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; + +namespace FilterLists.Agent.Infrastructure.Disk +{ + public static class ServiceCollectionExtensions + { + public static void AddArchiveRepository(this IServiceCollection services) + { + services.AddTransient(s => + { + var archiveSettings = s.GetService>().Value; + if (!Repository.IsValid(archiveSettings.RepositoryDirectory)) + Repository.Init(archiveSettings.RepositoryDirectory); + return new Repository(archiveSettings.RepositoryDirectory); + }); + } + } +} \ No newline at end of file diff --git a/src/FilterLists.Agent/Infrastructure/ListRepository.cs b/src/FilterLists.Agent/Infrastructure/Web/ListRepository.cs similarity index 96% rename from src/FilterLists.Agent/Infrastructure/ListRepository.cs rename to src/FilterLists.Agent/Infrastructure/Web/ListRepository.cs index 4c2faa7cb..96e52f9a9 100644 --- a/src/FilterLists.Agent/Infrastructure/ListRepository.cs +++ b/src/FilterLists.Agent/Infrastructure/Web/ListRepository.cs @@ -9,7 +9,7 @@ using JetBrains.Annotations; using Microsoft.Extensions.Logging; -namespace FilterLists.Agent.Infrastructure +namespace FilterLists.Agent.Infrastructure.Web { [UsedImplicitly] public class ListRepository : IListRepository diff --git a/src/FilterLists.Agent/Infrastructure/Web/ServiceCollectionExtensions.cs b/src/FilterLists.Agent/Infrastructure/Web/ServiceCollectionExtensions.cs new file mode 100644 index 000000000..0ff30ff85 --- /dev/null +++ b/src/FilterLists.Agent/Infrastructure/Web/ServiceCollectionExtensions.cs @@ -0,0 +1,18 @@ +using System; +using System.Net; +using FilterLists.Agent.Core.List; +using Microsoft.Extensions.DependencyInjection; +using Polly; + +namespace FilterLists.Agent.Infrastructure.Web +{ + public static class ServiceCollectionExtensions + { + public static void AddListRepository(this IServiceCollection services) + { + services.AddHttpClient().AddTransientHttpErrorPolicy(b => + b.OrResult(r => r.StatusCode == HttpStatusCode.TooManyRequests) + .WaitAndRetryAsync(5, i => i * TimeSpan.FromSeconds(3))); + } + } +} \ No newline at end of file