Fixes #2049 (cherry picked from commit 7da02c236aa03e6aef011130526040c1cb8399fc) (cherry picked from commit 024000275df3b2d3b884c2c2fbf0b86bd36a631a)pull/2154/head
parent
fa569f85b2
commit
5cc2db26e7
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
public class PackageGlobalMessageCheck : HealthCheckBase
|
||||
{
|
||||
private readonly IDeploymentInfoProvider _deploymentInfoProvider;
|
||||
|
||||
public PackageGlobalMessageCheck(IDeploymentInfoProvider deploymentInfoProvider)
|
||||
{
|
||||
_deploymentInfoProvider = deploymentInfoProvider;
|
||||
}
|
||||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
if (_deploymentInfoProvider.PackageGlobalMessage.IsNullOrWhiteSpace())
|
||||
{
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
var message = _deploymentInfoProvider.PackageGlobalMessage;
|
||||
HealthCheckResult result = HealthCheckResult.Notice;
|
||||
|
||||
if (message.StartsWith("Error:"))
|
||||
{
|
||||
message = message.Substring(6);
|
||||
result = HealthCheckResult.Error;
|
||||
}
|
||||
else if (message.StartsWith("Warn:"))
|
||||
{
|
||||
message = message.Substring(5);
|
||||
result = HealthCheckResult.Warning;
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(), result, message, "#package_maintainer_message");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue