Dont seed when in upgrade mode, and maintenance page is enabled (#17275)

This commit is contained in:
Nikolaj Geisle
2024-10-15 19:43:06 +02:00
committed by GitHub
parent b477cf50f2
commit 86557a01cf

View File

@@ -1,4 +1,6 @@
using Umbraco.Cms.Core;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
@@ -11,19 +13,21 @@ internal class SeedingNotificationHandler : INotificationAsyncHandler<UmbracoApp
private readonly IDocumentCacheService _documentCacheService;
private readonly IMediaCacheService _mediaCacheService;
private readonly IRuntimeState _runtimeState;
private readonly GlobalSettings _globalSettings;
public SeedingNotificationHandler(IDocumentCacheService documentCacheService, IMediaCacheService mediaCacheService, IRuntimeState runtimeState)
public SeedingNotificationHandler(IDocumentCacheService documentCacheService, IMediaCacheService mediaCacheService, IRuntimeState runtimeState, IOptions<GlobalSettings> globalSettings)
{
_documentCacheService = documentCacheService;
_mediaCacheService = mediaCacheService;
_runtimeState = runtimeState;
_globalSettings = globalSettings.Value;
}
public async Task HandleAsync(UmbracoApplicationStartedNotification notification,
CancellationToken cancellationToken)
{
if (_runtimeState.Level <= RuntimeLevel.Install)
if (_runtimeState.Level <= RuntimeLevel.Install || (_runtimeState.Level == RuntimeLevel.Upgrade && _globalSettings.ShowMaintenancePageWhenInUpgradeState))
{
return;
}