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.TrashLib/Repo/ConsoleMultiRepoUpdater.cs

30 lines
846 B

using Spectre.Console;
namespace Recyclarr.TrashLib.Repo;
public class ConsoleMultiRepoUpdater : IMultiRepoUpdater
{
private readonly IAnsiConsole _console;
private readonly IReadOnlyCollection<IUpdateableRepo> _repos;
public ConsoleMultiRepoUpdater(IAnsiConsole console, IReadOnlyCollection<IUpdateableRepo> repos)
{
_console = console;
_repos = repos;
}
public async Task UpdateAllRepositories(CancellationToken token)
{
var options = new ParallelOptions
{
CancellationToken = token,
MaxDegreeOfParallelism = 3
};
await _console.Status().StartAsync("Updating Git Repositories...", async _ =>
{
await Parallel.ForEachAsync(_repos, options, async (repo, innerToken) => await repo.Update(innerToken));
});
}
}