diff --git a/src/Umbraco.Infrastructure/Search/ExamineFinalComponent.cs b/src/Umbraco.Infrastructure/Search/ExamineFinalComponent.cs deleted file mode 100644 index 441d8af038..0000000000 --- a/src/Umbraco.Infrastructure/Search/ExamineFinalComponent.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using Umbraco.Cms.Core.Composing; -using Umbraco.Cms.Core.Runtime; - -namespace Umbraco.Cms.Infrastructure.Search -{ - /// - /// Executes after all other examine components have executed - /// - public sealed class ExamineFinalComponent : IComponent - { - BackgroundIndexRebuilder _indexRebuilder; - private readonly IMainDom _mainDom; - - public ExamineFinalComponent(BackgroundIndexRebuilder indexRebuilder, IMainDom mainDom) - { - _indexRebuilder = indexRebuilder; - _mainDom = mainDom; - } - - public void Initialize() - { - if (!_mainDom.IsMainDom) return; - - // TODO: Instead of waiting 5000 ms, we could add an event handler on to fulfilling the first request, then start? - _indexRebuilder.RebuildIndexes(true, TimeSpan.FromSeconds(5)); - } - - public void Terminate() - { - } - } -} diff --git a/src/Umbraco.Infrastructure/Search/ExamineFinalComposer.cs b/src/Umbraco.Infrastructure/Search/ExamineFinalComposer.cs deleted file mode 100644 index 037a3d1622..0000000000 --- a/src/Umbraco.Infrastructure/Search/ExamineFinalComposer.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Umbraco.Cms.Core.Composing; - -namespace Umbraco.Cms.Infrastructure.Search -{ - // examine's final composer composes after all user composers - // and *also* after ICoreComposer (in case IUserComposer is disabled) - [ComposeAfter(typeof(IUserComposer))] - [ComposeAfter(typeof(ICoreComposer))] - public class ExamineFinalComposer : ComponentComposer - { } -} diff --git a/src/Umbraco.Infrastructure/Search/ExamineNotificationHandler.cs b/src/Umbraco.Infrastructure/Search/ExamineNotificationHandler.cs index b10bf70c10..d22acb87e2 100644 --- a/src/Umbraco.Infrastructure/Search/ExamineNotificationHandler.cs +++ b/src/Umbraco.Infrastructure/Search/ExamineNotificationHandler.cs @@ -35,6 +35,7 @@ namespace Umbraco.Cms.Infrastructure.Search private readonly IValueSetBuilder _memberValueSetBuilder; private readonly BackgroundIndexRebuilder _backgroundIndexRebuilder; private readonly TaskHelper _taskHelper; + private readonly IRuntimeState _runtimeState; private readonly IScopeProvider _scopeProvider; private readonly ServiceContext _services; private readonly IMainDom _mainDom; @@ -60,7 +61,8 @@ namespace Umbraco.Cms.Infrastructure.Search IValueSetBuilder mediaValueSetBuilder, IValueSetBuilder memberValueSetBuilder, BackgroundIndexRebuilder backgroundIndexRebuilder, - TaskHelper taskHelper) + TaskHelper taskHelper, + IRuntimeState runtimeState) { _services = services; _scopeProvider = scopeProvider; @@ -71,6 +73,7 @@ namespace Umbraco.Cms.Infrastructure.Search _memberValueSetBuilder = memberValueSetBuilder; _backgroundIndexRebuilder = backgroundIndexRebuilder; _taskHelper = taskHelper; + _runtimeState = runtimeState; _mainDom = mainDom; _profilingLogger = profilingLogger; _logger = logger; @@ -114,7 +117,10 @@ namespace Umbraco.Cms.Infrastructure.Search s_deactivate_handlers = true; } - + if (_mainDom.IsMainDom && _runtimeState.Level >= RuntimeLevel.Run) + { + _backgroundIndexRebuilder.RebuildIndexes(true); + } }