Headless CMS and Content Managment Hub
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.
 
 
 
 
 

68 lines
2.2 KiB

// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Migrate_01.Migrations;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands;
namespace Migrate_01
{
public sealed class RebuildRunner
{
private readonly Rebuilder rebuilder;
private readonly PopulateGrainIndexes populateGrainIndexes;
private readonly RebuildOptions rebuildOptions;
public RebuildRunner(Rebuilder rebuilder, IOptions<RebuildOptions> rebuildOptions, PopulateGrainIndexes populateGrainIndexes)
{
Guard.NotNull(rebuilder, nameof(rebuilder));
Guard.NotNull(rebuildOptions, nameof(rebuildOptions));
Guard.NotNull(populateGrainIndexes, nameof(populateGrainIndexes));
this.rebuilder = rebuilder;
this.rebuildOptions = rebuildOptions.Value;
this.populateGrainIndexes = populateGrainIndexes;
}
public async Task RunAsync(CancellationToken ct)
{
if (rebuildOptions.Apps)
{
await rebuilder.RebuildAppsAsync(ct);
}
if (rebuildOptions.Schemas)
{
await rebuilder.RebuildSchemasAsync(ct);
}
if (rebuildOptions.Rules)
{
await rebuilder.RebuildRulesAsync(ct);
}
if (rebuildOptions.Assets)
{
await rebuilder.RebuildAssetsAsync(ct);
await rebuilder.RebuildAssetFoldersAsync(ct);
}
if (rebuildOptions.Contents)
{
await rebuilder.RebuildContentAsync(ct);
}
if (rebuildOptions.Indexes)
{
await populateGrainIndexes.UpdateAsync();
}
}
}
}