Broadend the error catching when building the examine dashboard
This commit is contained in:
@@ -187,8 +187,7 @@ public class ExamineIndexRebuilder : IIndexRebuilder
|
||||
{
|
||||
// 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 @@ public class ExamineIndexRebuilder : IIndexRebuilder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public class ExamineManagementController : UmbracoAuthorizedJsonController
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user