From dcd6f1fbf4938eac0988b41a766072ee115bea2c Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Wed, 4 Sep 2024 15:35:08 +0200 Subject: [PATCH] Fixed install issue --- .../NavigationInitializationHostedService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Services/Navigation/NavigationInitializationHostedService.cs b/src/Umbraco.Core/Services/Navigation/NavigationInitializationHostedService.cs index 274158d40d8a..a11b55b7b840 100644 --- a/src/Umbraco.Core/Services/Navigation/NavigationInitializationHostedService.cs +++ b/src/Umbraco.Core/Services/Navigation/NavigationInitializationHostedService.cs @@ -8,17 +8,27 @@ namespace Umbraco.Cms.Core.Services.Navigation; /// public sealed class NavigationInitializationHostedService : IHostedLifecycleService { + private readonly IRuntimeState _runtimeState; private readonly IDocumentNavigationManagementService _documentNavigationManagementService; private readonly IMediaNavigationManagementService _mediaNavigationManagementService; - public NavigationInitializationHostedService(IDocumentNavigationManagementService documentNavigationManagementService, IMediaNavigationManagementService mediaNavigationManagementService) + public NavigationInitializationHostedService( + IRuntimeState runtimeState, + IDocumentNavigationManagementService documentNavigationManagementService, + IMediaNavigationManagementService mediaNavigationManagementService) { + _runtimeState = runtimeState; _documentNavigationManagementService = documentNavigationManagementService; _mediaNavigationManagementService = mediaNavigationManagementService; } public async Task StartingAsync(CancellationToken cancellationToken) { + if(_runtimeState.Level < RuntimeLevel.Upgrade) + { + return; + } + await _documentNavigationManagementService.RebuildAsync(); await _documentNavigationManagementService.RebuildBinAsync(); await _mediaNavigationManagementService.RebuildAsync();