diff --git a/src/Umbraco.Infrastructure/Examine/ExamineIndexRebuilder.cs b/src/Umbraco.Infrastructure/Examine/ExamineIndexRebuilder.cs index 5fe98dca0bb3..bcaa77da7073 100644 --- a/src/Umbraco.Infrastructure/Examine/ExamineIndexRebuilder.cs +++ b/src/Umbraco.Infrastructure/Examine/ExamineIndexRebuilder.cs @@ -187,8 +187,7 @@ private void RebuildIndexes(bool onlyEmptyIndexes, TimeSpan delay, CancellationT { // If an index exists but it has zero docs we'll consider it empty and rebuild IIndex[] indexes = (onlyEmptyIndexes - ? _examineManager.Indexes.Where(x => - !x.IndexExists() || (x is IIndexStats stats && stats.GetDocumentCount() == 0)) + ? _examineManager.Indexes.Where(ShouldRebuild) : _examineManager.Indexes).ToArray(); if (indexes.Length == 0) @@ -228,4 +227,17 @@ private void RebuildIndexes(bool onlyEmptyIndexes, TimeSpan delay, CancellationT } } } + + private bool ShouldRebuild(IIndex index) + { + try + { + return !index.IndexExists() || (index is IIndexStats stats && stats.GetDocumentCount() == 0); + } + catch (Exception e) + { + _logger.LogError(e, "An error occured trying to get determine index shouldRebuild status for index {IndexName}. The index will NOT be considered for rebuilding", index.Name); + return false; + } + } } diff --git a/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs b/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs index 21cb7fdcd942..a2cd557a1c34 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ExamineManagementController.cs @@ -205,7 +205,7 @@ private ExamineIndexModel CreateModel(IIndex index) documentCount = indexDiag.GetDocumentCount(); fieldCount = indexDiag.GetFieldNames().Count(); } - catch (FileNotFoundException ex) + catch (Exception ex) { // Safe catch that will allow to rebuild a corrupted index documentCount = 0;