Radarr/src/NzbDrone.Core/HealthCheck/Checks/SqliteVersionCheck.cs

45 lines
1.3 KiB
C#
Raw Normal View History

using System;
using NLog;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Localization;
namespace NzbDrone.Core.HealthCheck.Checks
{
public class SqliteVersionCheck : HealthCheckBase
{
private readonly IDatabase _database;
private readonly Logger _logger;
public SqliteVersionCheck(IMainDatabase database, ILocalizationService localizationService, Logger logger)
: base(localizationService)
{
_database = database;
_logger = logger;
}
public override HealthCheck Check()
{
if (!OsInfo.IsLinux)
{
return new HealthCheck(GetType());
}
var sqliteVersion = _database.Version;
var supportedVersion = new Version("3.9.0");
if (sqliteVersion >= supportedVersion)
{
return new HealthCheck(GetType());
}
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("SqliteVersionCheckUpgradeRequiredMessage"), sqliteVersion, supportedVersion),
2021-06-05 19:26:09 +00:00
"#currently-installed-sqlite-version-is-not-supported");
}
public override bool CheckOnSchedule => false;
}
}