New: Translations support for Health Checks

(cherry picked from commit bfc036178487fe0b692f306a53f2a334cdf7f9d5)
This commit is contained in:
Qstick 2020-07-08 10:40:08 -04:00 committed by Mark McDowall
parent a22f598b0c
commit 560a9b63ca
40 changed files with 389 additions and 100 deletions

View File

@ -1,6 +1,8 @@
using NUnit.Framework;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
@ -9,6 +11,14 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
[TestFixture]
public class AppDataLocationFixture : CoreTest<AppDataLocationCheck>
{
[SetUp]
public void Setup()
{
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
[Test]
public void should_return_warning_when_app_data_is_child_of_startup_folder()
{

View File

@ -4,6 +4,7 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
@ -11,6 +12,14 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
[TestFixture]
public class DownloadClientCheckFixture : CoreTest<DownloadClientCheck>
{
[SetUp]
public void Setup()
{
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
[Test]
public void should_return_warning_when_download_client_has_not_been_configured()
{

View File

@ -6,6 +6,7 @@ using NzbDrone.Common.Disk;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
@ -54,6 +55,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<IDiskProvider>()
.Setup(x => x.FolderWritable(It.IsAny<string>()))
.Returns(true);
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private void GivenRootFolder(string folder)

View File

@ -4,6 +4,7 @@ using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
@ -41,6 +42,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<IProvideDownloadClient>()
.Setup(s => s.GetDownloadClients(It.IsAny<bool>()))
.Returns(new IDownloadClient[] { _downloadClient.Object });
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
[Test]

View File

@ -1,9 +1,10 @@
using System;
using System;
using System.Collections.Generic;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.ImportLists;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
@ -24,6 +25,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<IImportListStatusService>()
.Setup(v => v.GetBlockedProviders())
.Returns(_blockedImportLists);
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private Mock<IImportList> GivenImportList(int id, double backoffHours, double failureHours)

View File

@ -1,6 +1,8 @@
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
@ -8,6 +10,14 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
[TestFixture]
public class ImportMechanismCheckFixture : CoreTest<ImportMechanismCheck>
{
[SetUp]
public void Setup()
{
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private void GivenCompletedDownloadHandling(bool? enabled = null)
{
if (enabled.HasValue)

View File

@ -1,8 +1,10 @@
using System.Collections.Generic;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Torznab;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
@ -19,6 +21,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<IIndexerFactory>()
.Setup(v => v.All())
.Returns(_indexers);
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private void GivenIndexer(string baseUrl, string apiPath)

View File

@ -1,9 +1,10 @@
using System;
using System;
using System.Collections.Generic;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
@ -24,6 +25,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<IIndexerStatusService>()
.Setup(v => v.GetBlockedProviders())
.Returns(_blockedIndexers);
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private Mock<IIndexer> GivenIndexer(int id, double backoffHours, double failureHours)

View File

@ -1,8 +1,9 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
@ -22,6 +23,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.RssEnabled(It.IsAny<bool>()))
.Returns(new List<IIndexer>());
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private void GivenIndexer(bool supportsRss, bool supportsSearch)
@ -47,6 +52,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.RssEnabled(false))
.Returns(new List<IIndexer> { _indexerMock.Object });
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("recent indexer errors");
}
[Test]

View File

@ -3,6 +3,7 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
@ -26,6 +27,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.InteractiveSearchEnabled(It.IsAny<bool>()))
.Returns(new List<IIndexer>());
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private void GivenIndexer(bool supportsRss, bool supportsSearch)
@ -62,6 +67,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<IIndexerFactory>()
.Setup(s => s.InteractiveSearchEnabled(false))
.Returns(new List<IIndexer> { _indexerMock.Object });
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("recent indexer errors");
}
[Test]

View File

@ -1,9 +1,10 @@
using System;
using System;
using System.Collections.Generic;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
@ -24,6 +25,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<IIndexerStatusService>()
.Setup(v => v.GetBlockedProviders())
.Returns(_blockedIndexers);
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private Mock<IIndexer> GivenIndexer(int id, double backoffHours, double failureHours)

View File

@ -1,7 +1,9 @@
using System.Collections.Generic;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
@ -38,6 +40,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
Mocker.GetMock<ISeriesService>()
.Setup(v => v.GetAllSeries())
.Returns(series);
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
[Test]

View File

@ -5,6 +5,7 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
@ -13,6 +14,14 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
[TestFixture]
public class RootFolderCheckFixture : CoreTest<RootFolderCheck>
{
[SetUp]
public void Setup()
{
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private void GivenMissingRootFolder()
{
var series = Builder<Series>.CreateListOfSize(1)

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Text;
using Moq;
using NUnit.Framework;
@ -6,6 +6,7 @@ using NzbDrone.Common.Cloud;
using NzbDrone.Common.Http;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
@ -18,6 +19,10 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
public void Setup()
{
Mocker.SetConstant<ISonarrCloudRequestBuilder>(new SonarrCloudRequestBuilder());
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
private void GivenServerTime(DateTime dateTime)

View File

@ -4,6 +4,7 @@ using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.HealthCheck.Checks;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Update;
@ -12,6 +13,14 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
[TestFixture]
public class UpdateCheckFixture : CoreTest<UpdateCheck>
{
[SetUp]
public void Setup()
{
Mocker.GetMock<ILocalizationService>()
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
.Returns("Some Warning Message");
}
[Test]
public void should_return_error_when_app_folder_is_write_protected()
{

View File

@ -2,6 +2,7 @@ using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.Localization;
namespace NzbDrone.Core.HealthCheck.Checks
{
@ -12,7 +13,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IConfigFileProvider _configFileProvider;
private readonly Logger _logger;
public ApiKeyValidationCheck(IConfigFileProvider configFileProvider, Logger logger)
public ApiKeyValidationCheck(IConfigFileProvider configFileProvider, Logger logger, ILocalizationService localizationService)
: base(localizationService)
{
_configFileProvider = configFileProvider;
_logger = logger;
@ -24,7 +26,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
_logger.Warn("Please update your API key to be at least 20 characters long. You can do this via settings or the config file");
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Please update your API key to be at least 20 characters long. You can do this via settings or the config file", "#invalid-api-key");
return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("ApiKeyValidationHealthCheckMessage"), "#invalid-api-key");
}
return new HealthCheck(GetType());

View File

@ -1,5 +1,6 @@
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Localization;
namespace NzbDrone.Core.HealthCheck.Checks
{
@ -7,7 +8,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
private readonly IAppFolderInfo _appFolderInfo;
public AppDataLocationCheck(IAppFolderInfo appFolderInfo)
public AppDataLocationCheck(IAppFolderInfo appFolderInfo, ILocalizationService localizationService)
: base(localizationService)
{
_appFolderInfo = appFolderInfo;
}
@ -17,7 +19,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (_appFolderInfo.StartUpFolder.IsParentPath(_appFolderInfo.AppDataFolder) ||
_appFolderInfo.StartUpFolder.PathEquals(_appFolderInfo.AppDataFolder))
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Updating will not be possible to prevent deleting AppData on Update", "#updating-will-not-be-possible-to-prevent-deleting-appdata-on-update");
return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("AppDataLocationHealthCheckMessage"), "#updating-will-not-be-possible-to-prevent-deleting-appdata-on-update");
}
return new HealthCheck(GetType());

View File

@ -1,7 +1,8 @@
using System;
using System;
using System.Linq;
using NLog;
using NzbDrone.Core.Download;
using NzbDrone.Core.Localization;
using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.HealthCheck.Checks
@ -15,7 +16,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IProvideDownloadClient _downloadClientProvider;
private readonly Logger _logger;
public DownloadClientCheck(IProvideDownloadClient downloadClientProvider, Logger logger)
public DownloadClientCheck(IProvideDownloadClient downloadClientProvider, Logger logger, ILocalizationService localizationService)
: base(localizationService)
{
_downloadClientProvider = downloadClientProvider;
_logger = logger;
@ -27,7 +29,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (!downloadClients.Any())
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "No download client is available", "#no-download-client-is-available");
return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("DownloadClientCheckNoneAvailableHealthCheckMessage"), "#no-download-client-is-available");
}
foreach (var downloadClient in downloadClients)
@ -40,8 +42,10 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
_logger.Debug(ex, "Unable to communicate with {0}", downloadClient.Definition.Name);
var message = $"Unable to communicate with {downloadClient.Definition.Name}.";
return new HealthCheck(GetType(), HealthCheckResult.Error, $"{message} {ex.Message}", "#unable-to-communicate-with-download-client");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
$"{string.Format(_localizationService.GetLocalizedString("DownloadClientCheckUnableToCommunicateWithHealthCheckMessage"), downloadClient.Definition.Name)} {ex.Message}",
"#unable-to-communicate-with-download-client");
}
}

View File

@ -6,6 +6,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Localization;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.ThingiProvider.Events;
@ -24,8 +25,10 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly Logger _logger;
public DownloadClientRootFolderCheck(IProvideDownloadClient downloadClientProvider,
IRootFolderService rootFolderService,
Logger logger)
IRootFolderService rootFolderService,
Logger logger,
ILocalizationService localizationService)
: base(localizationService)
{
_downloadClientProvider = downloadClientProvider;
_rootFolderService = rootFolderService;
@ -48,7 +51,10 @@ namespace NzbDrone.Core.HealthCheck.Checks
foreach (var folder in folders)
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format("Download client {0} places downloads in the root folder {1}. You should not download to a root folder.", client.Definition.Name, folder.FullPath), "#downloads-in-root-folder");
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
string.Format(_localizationService.GetLocalizedString("DownloadClientRootFolderHealthCheckMessage"), client.Definition.Name, folder.FullPath),
"#downloads-in-root-folder");
}
}
catch (DownloadClientException ex)

View File

@ -4,6 +4,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Localization;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.ThingiProvider.Events;
@ -21,7 +22,9 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly Logger _logger;
public DownloadClientSortingCheck(IProvideDownloadClient downloadClientProvider,
Logger logger)
Logger logger,
ILocalizationService localizationService)
: base(localizationService)
{
_downloadClientProvider = downloadClientProvider;
_logger = logger;
@ -42,7 +45,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
$"Download client {clientName} has {status.SortingMode} sorting enabled for Sonarr's category. You should disable sorting in your download client to avoid import issues.",
string.Format(_localizationService.GetLocalizedString("DownloadClientSortingHealthCheckMessage"), clientName, status.SortingMode),
"#download-folder-and-library-folder-not-different-folders");
}
}

View File

@ -1,6 +1,7 @@
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Download;
using NzbDrone.Core.Localization;
using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.HealthCheck.Checks
@ -13,7 +14,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IDownloadClientFactory _providerFactory;
private readonly IDownloadClientStatusService _providerStatusService;
public DownloadClientStatusCheck(IDownloadClientFactory providerFactory, IDownloadClientStatusService providerStatusService)
public DownloadClientStatusCheck(IDownloadClientFactory providerFactory, IDownloadClientStatusService providerStatusService, ILocalizationService localizationService)
: base(localizationService)
{
_providerFactory = providerFactory;
_providerStatusService = providerStatusService;
@ -35,10 +37,16 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (backOffProviders.Count == enabledProviders.Count)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, "All download clients are unavailable due to failures", "#download-clients-are-unavailable-due-to-failures");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
_localizationService.GetLocalizedString("DownloadClientStatusAllClientHealthCheckMessage"),
"#download-clients-are-unavailable-due-to-failures");
}
return new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format("Download clients unavailable due to failures: {0}", string.Join(", ", backOffProviders.Select(v => v.Provider.Definition.Name))), "#download-clients-are-unavailable-due-to-failures");
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
string.Format(_localizationService.GetLocalizedString("DownloadClientStatusSingleClientHealthCheckMessage"), string.Join(", ", backOffProviders.Select(v => v.Provider.Definition.Name))),
"#download-clients-are-unavailable-due-to-failures");
}
}
}

View File

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Disk;
using NzbDrone.Core.ImportLists;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Tv.Events;
@ -16,7 +17,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IImportListFactory _importListFactory;
private readonly IDiskProvider _diskProvider;
public ImportListRootFolderCheck(IImportListFactory importListFactory, IDiskProvider diskProvider)
public ImportListRootFolderCheck(IImportListFactory importListFactory, IDiskProvider diskProvider, ILocalizationService localizationService)
: base(localizationService)
{
_importListFactory = importListFactory;
_diskProvider = diskProvider;
@ -49,11 +51,17 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (missingRootFolders.Count == 1)
{
var missingRootFolder = missingRootFolders.First();
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Missing root folder for import list(s): {FormatRootFolder(missingRootFolder.Key, missingRootFolder.Value)}", "#import-list-missing-root-folder");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("ImportListRootFolderMissingRootHealthCheckMessage"), FormatRootFolder(missingRootFolder.Key, missingRootFolder.Value)),
"#import-list-missing-root-folder");
}
var message = string.Format("Multiple root folders are missing for import lists: {0}", string.Join(" | ", missingRootFolders.Select(m => FormatRootFolder(m.Key, m.Value))));
return new HealthCheck(GetType(), HealthCheckResult.Error, message, "#import-list-missing-root-folder");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("ImportListRootFolderMultipleMissingRootsHealthCheckMessage"), string.Join(" | ", missingRootFolders.Select(m => FormatRootFolder(m.Key, m.Value)))),
"#import-list-missing-root-folder");
}
return new HealthCheck(GetType());

View File

@ -1,6 +1,7 @@
using System.Linq;
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.ImportLists;
using NzbDrone.Core.Localization;
using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.HealthCheck.Checks
@ -13,7 +14,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IImportListFactory _providerFactory;
private readonly IImportListStatusService _providerStatusService;
public ImportListStatusCheck(IImportListFactory providerFactory, IImportListStatusService providerStatusService)
public ImportListStatusCheck(IImportListFactory providerFactory, IImportListStatusService providerStatusService, ILocalizationService localizationService)
: base(localizationService)
{
_providerFactory = providerFactory;
_providerStatusService = providerStatusService;
@ -35,10 +37,16 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (backOffProviders.Count == enabledProviders.Count)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, "All import lists are unavailable due to failures", "#import-lists-are-unavailable-due-to-failures");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
_localizationService.GetLocalizedString("ImportListStatusAllUnavailableHealthCheckMessage"),
"#import-lists-are-unavailable-due-to-failures");
}
return new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format("Import lists unavailable due to failures: {0}", string.Join(", ", backOffProviders.Select(v => v.ImportList.Definition.Name))), "#import-lists-are-unavailable-due-to-failures");
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
string.Format(_localizationService.GetLocalizedString("ImportListStatusUnavailableHealthCheckMessage"), string.Join(", ", backOffProviders.Select(v => v.ImportList.Definition.Name))),
"#import-lists-are-unavailable-due-to-failures");
}
}
}

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Configuration;
@ -6,6 +6,7 @@ using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients.Nzbget;
using NzbDrone.Core.Download.Clients.Sabnzbd;
using NzbDrone.Core.Localization;
using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.HealthCheck.Checks
@ -18,7 +19,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IConfigService _configService;
private readonly IProvideDownloadClient _provideDownloadClient;
public ImportMechanismCheck(IConfigService configService, IProvideDownloadClient provideDownloadClient)
public ImportMechanismCheck(IConfigService configService, IProvideDownloadClient provideDownloadClient, ILocalizationService localizationService)
: base(localizationService)
{
_configService = configService;
_provideDownloadClient = provideDownloadClient;
@ -49,25 +51,39 @@ namespace NzbDrone.Core.HealthCheck.Checks
// Migration helper logic
if (!downloadClientIsLocalHost)
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Multi-Computer unsupported)", "#completedfailed-download-handling");
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
_localizationService.GetLocalizedString("ImportMechanismEnableCompletedDownloadHandlingIfPossibleMultiComputerHealthCheckMessage"),
"#completedfailed-download-handling");
}
if (downloadClients.All(v => v.DownloadClient is Sabnzbd))
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Sabnzbd)", "#completedfailed-download-handling");
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
$"{_localizationService.GetLocalizedString("ImportMechanismEnableCompletedDownloadHandlingIfPossibleHealthCheckMessage")} (Sabnzbd)",
"#completedfailed-download-handling");
}
if (downloadClients.All(v => v.DownloadClient is Nzbget))
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Nzbget)", "#completedfailed-download-handling");
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
$"{_localizationService.GetLocalizedString("ImportMechanismEnableCompletedDownloadHandlingIfPossibleHealthCheckMessage")} (Nzbget)",
"#completedfailed-download-handling");
}
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible", "#completedfailed-download-handling");
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
_localizationService.GetLocalizedString("ImportMechanismEnableCompletedDownloadHandlingIfPossibleHealthCheckMessage"),
"#completedfailed-download-handling");
}
if (!_configService.EnableCompletedDownloadHandling)
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling");
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
_localizationService.GetLocalizedString("ImportMechanismHandlingDisabledHealthCheckMessage"));
}
return new HealthCheck(GetType());

View File

@ -3,6 +3,7 @@ using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Torznab;
using NzbDrone.Core.Localization;
using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.HealthCheck.Checks
@ -14,7 +15,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
private readonly IIndexerFactory _providerFactory;
public IndexerJackettAllCheck(IIndexerFactory providerFactory)
public IndexerJackettAllCheck(IIndexerFactory providerFactory, ILocalizationService localizationService)
: base(localizationService)
{
_providerFactory = providerFactory;
}
@ -37,8 +39,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
string.Format("Indexers using the unsupported Jackett 'all' endpoint: {0}",
string.Join(", ", jackettAllProviders.Select(i => i.Name))),
string.Format(_localizationService.GetLocalizedString("IndexerJackettAllHealthCheckMessage"), string.Join(", ", jackettAllProviders.Select(i => i.Name))),
"#jackett-all-endpoint-used");
}
}

View File

@ -2,6 +2,7 @@ using System;
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Localization;
using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.HealthCheck.Checks
@ -14,7 +15,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IIndexerFactory _providerFactory;
private readonly IIndexerStatusService _providerStatusService;
public IndexerLongTermStatusCheck(IIndexerFactory providerFactory, IIndexerStatusService providerStatusService)
public IndexerLongTermStatusCheck(IIndexerFactory providerFactory, IIndexerStatusService providerStatusService, ILocalizationService localizationService)
: base(localizationService)
{
_providerFactory = providerFactory;
_providerStatusService = providerStatusService;
@ -40,14 +42,13 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
return new HealthCheck(GetType(),
HealthCheckResult.Error,
"All indexers are unavailable due to failures for more than 6 hours",
_localizationService.GetLocalizedString("IndexerLongTermStatusAllUnavailableHealthCheckMessage"),
"#indexers-are-unavailable-due-to-failures");
}
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
string.Format("Indexers unavailable due to failures for more than 6 hours: {0}",
string.Join(", ", backOffProviders.Select(v => v.Provider.Definition.Name))),
string.Format(_localizationService.GetLocalizedString("IndexerLongTermStatusUnavailableHealthCheckMessage"), string.Join(", ", backOffProviders.Select(v => v.Provider.Definition.Name))),
"#indexers-are-unavailable-due-to-failures");
}
}

View File

@ -1,5 +1,6 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Localization;
using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.HealthCheck.Checks
@ -12,7 +13,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
private readonly IIndexerFactory _indexerFactory;
public IndexerRssCheck(IIndexerFactory indexerFactory)
public IndexerRssCheck(IIndexerFactory indexerFactory, ILocalizationService localizationService)
: base(localizationService)
{
_indexerFactory = indexerFactory;
}
@ -23,14 +25,14 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (enabled.Empty())
{
return new HealthCheck(GetType(), HealthCheckResult.Error, "No indexers available with RSS sync enabled, Sonarr will not grab new releases automatically");
return new HealthCheck(GetType(), HealthCheckResult.Error, _localizationService.GetLocalizedString("IndexerRssNoIndexersEnabledHealthCheckMessage"));
}
var active = _indexerFactory.RssEnabled(true);
if (active.Empty())
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "All rss-capable indexers are temporarily unavailable due to recent indexer errors");
return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("IndexerRssNoIndexersAvailableHealthCheckMessage"));
}
return new HealthCheck(GetType());

View File

@ -1,5 +1,6 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Localization;
using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.HealthCheck.Checks
@ -12,7 +13,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
private readonly IIndexerFactory _indexerFactory;
public IndexerSearchCheck(IIndexerFactory indexerFactory)
public IndexerSearchCheck(IIndexerFactory indexerFactory, ILocalizationService localizationService)
: base(localizationService)
{
_indexerFactory = indexerFactory;
}
@ -23,21 +25,21 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (automaticSearchEnabled.Empty())
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "No indexers available with Automatic Search enabled, Sonarr will not provide any automatic search results", "#no-indexers-available-with-automatic-search-enabled-sonarr-will-not-provide-any-automatic-search-results");
return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("IndexerSearchNoAutomaticHealthCheckMessage"), "#no-indexers-available-with-automatic-search-enabled-sonarr-will-not-provide-any-automatic-search-results");
}
var interactiveSearchEnabled = _indexerFactory.InteractiveSearchEnabled(false);
if (interactiveSearchEnabled.Empty())
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "No indexers available with Interactive Search enabled, Sonarr will not provide any interactive search results", "#no-indexers-available-with-interactive-search-enabled");
return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("IndexerSearchNoInteractiveHealthCheckMessage"), "#no-indexers-available-with-interactive-search-enabled");
}
var active = _indexerFactory.AutomaticSearchEnabled(true);
if (active.Empty())
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "All search-capable indexers are temporarily unavailable due to recent indexer errors", "#indexers-are-unavailable-due-to-failures");
return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("IndexerSearchNoAvailableIndexersHealthCheckMessage"), "#indexers-are-unavailable-due-to-failures");
}
return new HealthCheck(GetType());

View File

@ -1,7 +1,8 @@
using System;
using System;
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Localization;
using NzbDrone.Core.ThingiProvider.Events;
namespace NzbDrone.Core.HealthCheck.Checks
@ -14,7 +15,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IIndexerFactory _providerFactory;
private readonly IIndexerStatusService _providerStatusService;
public IndexerStatusCheck(IIndexerFactory providerFactory, IIndexerStatusService providerStatusService)
public IndexerStatusCheck(IIndexerFactory providerFactory, IIndexerStatusService providerStatusService, ILocalizationService localizationService)
: base(localizationService)
{
_providerFactory = providerFactory;
_providerStatusService = providerStatusService;
@ -38,10 +40,16 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (backOffProviders.Count == enabledProviders.Count)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, "All indexers are unavailable due to failures", "#indexers-are-unavailable-due-to-failures");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
_localizationService.GetLocalizedString("IndexerStatusAllUnavailableHealthCheckMessage"),
"#indexers-are-unavailable-due-to-failures");
}
return new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format("Indexers unavailable due to failures: {0}", string.Join(", ", backOffProviders.Select(v => v.Provider.Definition.Name))), "#indexers-are-unavailable-due-to-failures");
return new HealthCheck(GetType(),
HealthCheckResult.Warning,
string.Format(_localizationService.GetLocalizedString("IndexerStatusUnavailableHealthCheckMessage"), string.Join(", ", backOffProviders.Select(v => v.Provider.Definition.Name))),
"#indexers-are-unavailable-due-to-failures");
}
}
}

View File

@ -1,5 +1,6 @@
using System.Linq;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.HealthCheck.Checks
@ -9,7 +10,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IDiskProvider _diskProvider;
private readonly ISeriesService _seriesService;
public MountCheck(IDiskProvider diskProvider, ISeriesService seriesService)
public MountCheck(IDiskProvider diskProvider, ISeriesService seriesService, ILocalizationService localizationService)
: base(localizationService)
{
_diskProvider = diskProvider;
_seriesService = seriesService;
@ -26,7 +28,10 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (mounts.Any())
{
return new HealthCheck(GetType(), HealthCheckResult.Error, "Mount containing a series path is mounted read-only: " + string.Join(",", mounts.Select(m => m.Name)), "#series-mount-ro");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
$"{_localizationService.GetLocalizedString("MountHealthCheckMessage")}{string.Join(", ", mounts.Select(m => m.Name))}",
"#series-mount-ro");
}
return new HealthCheck(GetType());

View File

@ -1,5 +1,6 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Localization;
namespace NzbDrone.Core.HealthCheck.Checks
{
@ -7,7 +8,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
private readonly IDeploymentInfoProvider _deploymentInfoProvider;
public PackageGlobalMessageCheck(IDeploymentInfoProvider deploymentInfoProvider)
public PackageGlobalMessageCheck(IDeploymentInfoProvider deploymentInfoProvider, ILocalizationService localizationService)
: base(localizationService)
{
_deploymentInfoProvider = deploymentInfoProvider;
}

View File

@ -6,6 +6,7 @@ using NzbDrone.Common.Cloud;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Localization;
namespace NzbDrone.Core.HealthCheck.Checks
{
@ -18,7 +19,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IHttpRequestBuilderFactory _cloudRequestBuilder;
public ProxyCheck(ISonarrCloudRequestBuilder cloudRequestBuilder, IConfigService configService, IHttpClient client, Logger logger)
public ProxyCheck(ISonarrCloudRequestBuilder cloudRequestBuilder, IConfigService configService, IHttpClient client, Logger logger, ILocalizationService localizationService)
: base(localizationService)
{
_configService = configService;
_client = client;
@ -38,7 +40,10 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (!addresses.Any())
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Failed to resolve the IP Address for the Configured Proxy Host {0}", _configService.ProxyHostname), "#proxy-failed-resolve-ip");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("ProxyResolveIpHealthCheckMessage"), _configService.ProxyHostname),
"#proxy-failed-resolve-ip");
}
var request = _cloudRequestBuilder.Create()
@ -53,13 +58,21 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (response.StatusCode == HttpStatusCode.BadRequest)
{
_logger.Error("Proxy Health Check failed: {0}", response.StatusCode);
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Failed to test proxy. StatusCode: {response.StatusCode}", "#proxy-failed-test");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("ProxyBadRequestHealthCheckMessage"), response.StatusCode),
"#proxy-failed-test");
}
}
catch (Exception ex)
{
_logger.Error(ex, "Proxy Health Check failed");
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Failed to test proxy: {request.Url}", "#proxy-failed-test");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("ProxyFailedToTestHealthCheckMessage"), request.Url),
"#proxy-failed-test");
}
return new HealthCheck(GetType());

View File

@ -1,6 +1,7 @@
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaFiles.Events;
namespace NzbDrone.Core.HealthCheck.Checks
@ -12,7 +13,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IConfigService _configService;
private readonly IDiskProvider _diskProvider;
public RecyclingBinCheck(IConfigService configService, IDiskProvider diskProvider)
public RecyclingBinCheck(IConfigService configService, IDiskProvider diskProvider, ILocalizationService localizationService)
: base(localizationService)
{
_configService = configService;
_diskProvider = diskProvider;
@ -29,7 +31,10 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (!_diskProvider.FolderWritable(recycleBin))
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Unable to write to configured recycling bin folder: {recycleBin}. Ensure this path exists and is writable by the user running Sonarr", "#cannot-write-recycle-bin");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("RecycleBinUnableToWriteHealthCheckMessage"), recycleBin),
"#cannot-write-recycle-bin");
}
return new HealthCheck(GetType());

View File

@ -10,6 +10,7 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.ThingiProvider.Events;
@ -32,7 +33,9 @@ namespace NzbDrone.Core.HealthCheck.Checks
IProvideDownloadClient downloadClientProvider,
IConfigService configService,
IOsInfo osInfo,
Logger logger)
Logger logger,
ILocalizationService localizationService)
: base(localizationService)
{
_diskProvider = diskProvider;
_downloadClientProvider = downloadClientProvider;
@ -65,30 +68,30 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
if (!status.IsLocalhost)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Remote download client {0} places downloads in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.", client.Definition.Name, folder.FullPath, _osInfo.Name), "#bad-remote-path-mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingWrongOSPathHealthCheckMessage"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#bad-remote-path-mapping");
}
if (_osInfo.IsDocker)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("You are using docker; download client {0} reported files in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.", client.Definition.Name, folder.FullPath, _osInfo.Name), "#docker-bad-remote-path-mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingBadDockerPathHealthCheckMessage"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#docker-bad-remote-path-mapping");
}
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Local download client {0} places downloads in {1} but this is not a valid {2} path. Review your download client settings.", client.Definition.Name, folder.FullPath, _osInfo.Name), "#bad-download-client-settings");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingLocalWrongOSPathHealthCheckMessage"), client.Definition.Name, folder.FullPath, _osInfo.Name), "#bad-download-client-settings");
}
if (!_diskProvider.FolderExists(folder.FullPath))
{
if (_osInfo.IsDocker)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("You are using docker; download client {0} places downloads in {1} but this directory does not appear to exist inside the container. Review your remote path mappings and container volume settings.", client.Definition.Name, folder.FullPath), "#docker-bad-remote-path-mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingDockerFolderMissingHealthCheckMessage"), client.Definition.Name, folder.FullPath), "#docker-bad-remote-path-mapping");
}
if (!status.IsLocalhost)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Remote download client {0} places downloads in {1} but this directory does not appear to exist. Likely missing or incorrect remote path mapping.", client.Definition.Name, folder.FullPath), "#bad-remote-path-mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingLocalFolderMissingHealthCheckMessage"), client.Definition.Name, folder.FullPath), "#bad-remote-path-mapping");
}
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Download client {0} places downloads in {1} but Sonarr cannot see this directory. You may need to adjust the folder's permissions.", client.Definition.Name, folder.FullPath), "#permissions-error");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingGenericPermissionsHealthCheckMessage"), client.Definition.Name, folder.FullPath), "#permissions-error");
}
}
}
@ -126,12 +129,12 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (_diskProvider.FileExists(episodePath))
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Sonarr can see but not access downloaded episode {0}. Likely permissions error.", episodePath), "#permissions-error");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingDownloadPermissionsHealthCheckMessage"), episodePath), "#permissions-error");
}
// If the file doesn't exist but EpisodeInfo is not null then the message is coming from
// ImportApprovedEpisodes and the file must have been removed part way through processing
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("File {0} was removed part way through processing.", episodePath), "#remote-path-file-removed");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingFileRemovedHealthCheckMessage"), episodePath), "#remote-path-file-removed");
}
// If the previous case did not match then the failure occured in DownloadedEpisodeImportService,
@ -153,42 +156,42 @@ namespace NzbDrone.Core.HealthCheck.Checks
// that the user realises something is wrong.
if (dlpath.IsNullOrWhiteSpace())
{
return new HealthCheck(GetType(), HealthCheckResult.Error, "Sonarr failed to import (an) episode(s). Check your logs for details.", "#remote-path-import-failed");
return new HealthCheck(GetType(), HealthCheckResult.Error, _localizationService.GetLocalizedString("RemotePathMappingImportFailedHealthCheckMessage"), "#remote-path-import-failed");
}
if (!dlpath.IsPathValid(PathValidationType.CurrentOs))
{
if (!status.IsLocalhost)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Remote download client {0} reported files in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.", client.Definition.Name, dlpath, _osInfo.Name), "#bad-remote-path-mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingFilesWrongOSPathHealthCheckMessage"), client.Definition.Name, dlpath, _osInfo.Name), "#bad-remote-path-mapping");
}
if (_osInfo.IsDocker)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("You are using docker; download client {0} reported files in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.", client.Definition.Name, dlpath, _osInfo.Name), "#docker-bad-remote-path-mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingFilesBadDockerPathHealthCheckMessage"), client.Definition.Name, dlpath, _osInfo.Name), "#docker-bad-remote-path-mapping");
}
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Local download client {0} reported files in {1} but this is not a valid {2} path. Review your download client settings.", client.Definition.Name, dlpath, _osInfo.Name), "#bad-download-client-settings");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingFilesLocalWrongOSPathHealthCheckMessage"), client.Definition.Name, dlpath, _osInfo.Name), "#bad-download-client-settings");
}
if (_diskProvider.FolderExists(dlpath))
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Sonarr can see but not access download directory {0}. Likely permissions error.", dlpath), "#permissions-error");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingFolderPermissionsHealthCheckMessage"), dlpath), "#permissions-error");
}
// if it's a remote client/docker, likely missing path mappings
if (_osInfo.IsDocker)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Sonarr can see but not access download directory {0}. Likely permissions error.", client.Definition.Name, dlpath), "#docker-bad-remote-path-mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingFolderPermissionsHealthCheckMessage"), client.Definition.Name, dlpath), "#docker-bad-remote-path-mapping");
}
if (!status.IsLocalhost)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Remote download client {0} reported files in {1} but this directory does not appear to exist. Likely missing remote path mapping.", client.Definition.Name, dlpath), "#bad-remote-path-mapping");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingRemoteDownloadClientHealthCheckMessage"), client.Definition.Name, dlpath), "#bad-remote-path-mapping");
}
// path mappings shouldn't be needed locally so probably a permissions issue
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format("Download client {0} reported files in {1} but Sonarr cannot see this directory. You may need to adjust the folder's permissions.", client.Definition.Name, dlpath), "#permissions-error");
return new HealthCheck(GetType(), HealthCheckResult.Error, string.Format(_localizationService.GetLocalizedString("RemotePathMappingFilesGenericPermissionsHealthCheckMessage"), client.Definition.Name, dlpath), "#permissions-error");
}
catch (DownloadClientException ex)
{

View File

@ -1,5 +1,6 @@
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Tv.Events;
@ -12,7 +13,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
private readonly ISeriesService _seriesService;
public RemovedSeriesCheck(ISeriesService seriesService)
public RemovedSeriesCheck(ISeriesService seriesService, ILocalizationService localizationService)
: base(localizationService)
{
_seriesService = seriesService;
}
@ -30,10 +32,16 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (deletedSeries.Count == 1)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Series {seriesText} was removed from TheTVDB", "#series-removed-from-thetvdb");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("RemovedSeriesSingleRemovedHealthCheckMessage"), seriesText),
"#series-removed-from-thetvdb");
}
return new HealthCheck(GetType(), HealthCheckResult.Error, $"Series {seriesText} were removed from TheTVDB", "#series-removed-from-thetvdb");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("RemovedSeriesMultipleRemovedHealthCheckMessage"), seriesText),
"#series-removed-from-thetvdb");
}
public bool ShouldCheckOnEvent(SeriesDeletedEvent deletedEvent)

View File

@ -1,5 +1,6 @@
using System.Linq;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Localization;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Tv;
@ -17,7 +18,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IDiskProvider _diskProvider;
private readonly IRootFolderService _rootFolderService;
public RootFolderCheck(ISeriesService seriesService, IDiskProvider diskProvider, IRootFolderService rootFolderService)
public RootFolderCheck(ISeriesService seriesService, IDiskProvider diskProvider, IRootFolderService rootFolderService, ILocalizationService localizationService)
: base(localizationService)
{
_seriesService = seriesService;
_diskProvider = diskProvider;
@ -37,11 +39,16 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
if (missingRootFolders.Count == 1)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, "Missing root folder: " + missingRootFolders.First(), "#missing-root-folder");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("RootFolderMissingHealthCheckMessage"), missingRootFolders.First()),
"#missing-root-folder");
}
var message = string.Format("Multiple root folders are missing: {0}", string.Join(" | ", missingRootFolders));
return new HealthCheck(GetType(), HealthCheckResult.Error, message, "#missing-root-folder");
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format(_localizationService.GetLocalizedString("RootFolderMultipleMissingHealthCheckMessage"), string.Join(" | ", missingRootFolders)),
"#missing-root-folder");
}
return new HealthCheck(GetType());

View File

@ -1,8 +1,9 @@
using System;
using System;
using NLog;
using NzbDrone.Common.Cloud;
using NzbDrone.Common.Http;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Localization;
namespace NzbDrone.Core.HealthCheck.Checks
{
@ -12,7 +13,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IHttpRequestBuilderFactory _cloudRequestBuilder;
private readonly Logger _logger;
public SystemTimeCheck(IHttpClient client, ISonarrCloudRequestBuilder cloudRequestBuilder, Logger logger)
public SystemTimeCheck(IHttpClient client, ISonarrCloudRequestBuilder cloudRequestBuilder, Logger logger, ILocalizationService localizationService)
: base(localizationService)
{
_client = client;
_cloudRequestBuilder = cloudRequestBuilder.Services;
@ -33,7 +35,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
if (Math.Abs(result.DateTimeUtc.Subtract(systemTime).TotalDays) >= 1)
{
_logger.Error("System time mismatch. SystemTime: {0} Expected Time: {1}. Update system time", systemTime, result.DateTimeUtc);
return new HealthCheck(GetType(), HealthCheckResult.Error, $"System time is off by more than 1 day. Scheduled tasks may not run correctly until the time is corrected", "#system-time-off");
return new HealthCheck(GetType(), HealthCheckResult.Error, _localizationService.GetLocalizedString("SystemTimeHealthCheckMessage"), "#system-time-off");
}
return new HealthCheck(GetType());

View File

@ -5,6 +5,7 @@ using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Update;
namespace NzbDrone.Core.HealthCheck.Checks
@ -22,7 +23,9 @@ namespace NzbDrone.Core.HealthCheck.Checks
IAppFolderInfo appFolderInfo,
ICheckUpdateService checkUpdateService,
IConfigFileProvider configFileProvider,
IOsInfo osInfo)
IOsInfo osInfo,
ILocalizationService localizationService)
: base(localizationService)
{
_diskProvider = diskProvider;
_appFolderInfo = appFolderInfo;
@ -44,15 +47,15 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format("Cannot install update because startup folder '{0}' is in an App Translocation folder.", startupFolder),
"#cannot-install-update-because-startup-folder-is-in-an-app-translocation-folder");
string.Format(_localizationService.GetLocalizedString("UpdateStartupTranslocationHealthCheckMessage"), startupFolder),
"#cannot-install-update-because-startup-folder-is-in-an-app-translocation-folder.");
}
if (!_diskProvider.FolderWritable(startupFolder))
{
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format("Cannot install update because startup folder '{0}' is not writable by the user '{1}'.", startupFolder, Environment.UserName),
string.Format(_localizationService.GetLocalizedString("UpdateStartupNotWritableHealthCheckMessage"), startupFolder, Environment.UserName),
"#cannot-install-update-because-startup-folder-is-not-writable-by-the-user");
}
@ -60,14 +63,14 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
return new HealthCheck(GetType(),
HealthCheckResult.Error,
string.Format("Cannot install update because UI folder '{0}' is not writable by the user '{1}'.", uiFolder, Environment.UserName),
string.Format(_localizationService.GetLocalizedString("UpdateUINotWritableHealthCheckMessage"), uiFolder, Environment.UserName),
"#cannot-install-update-because-ui-folder-is-not-writable-by-the-user");
}
}
if (BuildInfo.BuildDateTime < DateTime.UtcNow.AddDays(-14) && _checkUpdateService.AvailableUpdate() != null)
{
return new HealthCheck(GetType(), HealthCheckResult.Warning, "New update is available");
return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("UpdateAvailableHealthCheckMessage"));
}
return new HealthCheck(GetType());

View File

@ -1,7 +1,16 @@
namespace NzbDrone.Core.HealthCheck
using NzbDrone.Core.Localization;
namespace NzbDrone.Core.HealthCheck
{
public abstract class HealthCheckBase : IProvideHealthCheck
{
public readonly ILocalizationService _localizationService;
public HealthCheckBase(ILocalizationService localizationService)
{
_localizationService = localizationService;
}
public abstract HealthCheck Check();
public virtual bool CheckOnStartup => true;

View File

@ -1,9 +1,17 @@
{
"Added": "Added",
"ApiKeyValidationHealthCheckMessage": "Please update your API key to be at least 20 characters long. You can do this via settings or the config file",
"AppDataLocationHealthCheckMessage": "Updating will not be possible to prevent deleting AppData on Update",
"ApplyChanges": "Apply Changes",
"AutomaticAdd": "Automatic Add",
"Browser Reload Required": "Browser Reload Required",
"CountSeasons": "{count} seasons",
"DownloadClientCheckNoneAvailableHealthCheckMessage": "No download client is available",
"DownloadClientCheckUnableToCommunicateWithHealthCheckMessage": "Unable to communicate with {0}.",
"DownloadClientRootFolderHealthCheckMessage": "Download client {0} places downloads in the root folder {1}. You should not download to a root folder.",
"DownloadClientSortingHealthCheckMessage": "Download client {0} has {1} sorting enabled for Sonarr's category. You should disable sorting in your download client to avoid import issues.",
"DownloadClientStatusAllClientHealthCheckMessage": "All download clients are unavailable due to failures",
"DownloadClientStatusSingleClientHealthCheckMessage": "Download clients unavailable due to failures: {0}",
"EditSelectedDownloadClients": "Edit Selected Download Clients",
"EditSelectedImportLists": "Edit Selected Import Lists",
"EditSelectedIndexers": "Edit Selected Indexers",
@ -15,9 +23,27 @@
"Ended": "Ended",
"HiddenClickToShow": "Hidden, click to show",
"HideAdvanced": "Hide Advanced",
"ImportListRootFolderMissingRootHealthCheckMessage": "Missing root folder for import list(s): {0}",
"ImportListRootFolderMultipleMissingRootsHealthCheckMessage": "Multiple root folders are missing for import lists: {0}",
"ImportListStatusAllUnavailableHealthCheckMessage": "All lists are unavailable due to failures",
"ImportListStatusUnavailableHealthCheckMessage": "Lists unavailable due to failures: {0}",
"ImportMechanismEnableCompletedDownloadHandlingIfPossibleHealthCheckMessage": "Enable Completed Download Handling if possible",
"ImportMechanismEnableCompletedDownloadHandlingIfPossibleMultiComputerHealthCheckMessage": "Enable Completed Download Handling if possible (Multi-Computer unsupported)",
"ImportMechanismHandlingDisabledHealthCheckMessage": "Enable Completed Download Handling",
"IndexerJackettAllHealthCheckMessage": "Indexers using the unsupported Jackett 'all' endpoint: {0}",
"IndexerLongTermStatusAllUnavailableHealthCheckMessage": "All indexers are unavailable due to failures for more than 6 hours",
"IndexerLongTermStatusUnavailableHealthCheckMessage": "Indexers unavailable due to failures for more than 6 hours: {0}",
"IndexerRssNoIndexersAvailableHealthCheckMessage": "All rss-capable indexers are temporarily unavailable due to recent indexer errors",
"IndexerRssNoIndexersEnabledHealthCheckMessage": "No indexers available with RSS sync enabled, Sonarr will not grab new releases automatically",
"IndexerSearchNoAutomaticHealthCheckMessage": "No indexers available with Automatic Search enabled, Sonarr will not provide any automatic search results",
"IndexerSearchNoAvailableIndexersHealthCheckMessage": "All search-capable indexers are temporarily unavailable due to recent indexer errors",
"IndexerSearchNoInteractiveHealthCheckMessage": "No indexers available with Interactive Search enabled, Sonarr will not provide any interactive search results",
"IndexerStatusAllUnavailableHealthCheckMessage": "All indexers are unavailable due to failures",
"IndexerStatusUnavailableHealthCheckMessage": "Indexers unavailable due to failures: {0}",
"Language": "Language",
"Language that Sonarr will use for UI": "Language that Sonarr will use for UI",
"Monitored": "Monitored",
"MountHealthCheckMessage": "Mount containing a series path is mounted read-only: ",
"Network": "Network",
"NextAiring": "Next Airing",
"NoSeasons": "No seasons",
@ -26,15 +52,43 @@
"Path": "Path",
"PreviousAiring": "Previous Airing",
"Priority": "Priority",
"ProxyBadRequestHealthCheckMessage": "Failed to test proxy. Status Code: {0}",
"ProxyFailedToTestHealthCheckMessage": "Failed to test proxy: {0}",
"ProxyResolveIpHealthCheckMessage": "Failed to resolve the IP Address for the Configured Proxy Host {0}",
"QualityProfile": "Quality Profile",
"RecycleBinUnableToWriteHealthCheckMessage": "Unable to write to configured recycling bin folder: {0}. Ensure this path exists and is writable by the user running Sonarr",
"RefreshSeries": "Refresh Series",
"RemotePathMappingBadDockerPathHealthCheckMessage": "You are using docker; download client {0} places downloads in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.",
"RemotePathMappingDockerFolderMissingHealthCheckMessage": "You are using docker; download client {0} places downloads in {1} but this directory does not appear to exist inside the container. Review your remote path mappings and container volume settings.",
"RemotePathMappingDownloadPermissionsHealthCheckMessage": "Sonarr can see but not access downloaded episode {0}. Likely permissions error.",
"RemotePathMappingFileRemovedHealthCheckMessage": "File {0} was removed part way through processing.",
"RemotePathMappingFilesBadDockerPathHealthCheckMessage": "You are using docker; download client {0} reported files in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.",
"RemotePathMappingFilesGenericPermissionsHealthCheckMessage": "Download client {0} reported files in {1} but Sonarr cannot see this directory. You may need to adjust the folder's permissions.",
"RemotePathMappingFilesLocalWrongOSPathHealthCheckMessage": "Local download client {0} reported files in {1} but this is not a valid {2} path. Review your download client settings.",
"RemotePathMappingFilesWrongOSPathHealthCheckMessage": "Remote download client {0} reported files in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.",
"RemotePathMappingFolderPermissionsHealthCheckMessage": "Sonarr can see but not access download directory {0}. Likely permissions error.",
"RemotePathMappingGenericPermissionsHealthCheckMessage": "Download client {0} places downloads in {1} but Sonarr cannot see this directory. You may need to adjust the folder's permissions.",
"RemotePathMappingImportFailedHealthCheckMessage": "Sonarr failed to import (an) episode(s). Check your logs for details.",
"RemotePathMappingLocalFolderMissingHealthCheckMessage": "Remote download client {0} places downloads in {1} but this directory does not appear to exist. Likely missing or incorrect remote path mapping.",
"RemotePathMappingLocalWrongOSPathHealthCheckMessage": "Local download client {0} places downloads in {1} but this is not a valid {2} path. Review your download client settings.",
"RemotePathMappingRemoteDownloadClientHealthCheckMessage": "Remote download client {0} reported files in {1} but this directory does not appear to exist. Likely missing remote path mapping.",
"RemotePathMappingWrongOSPathHealthCheckMessage": "Remote download client {0} places downloads in {1} but this is not a valid {2} path. Review your remote path mappings and download client settings.",
"RemoveCompletedDownloads": "Remove Completed Downloads",
"RemoveFailedDownloads": "Remove Failed Downloads",
"RemovedSeriesMultipleRemovedHealthCheckMessage": "Series {0} were removed from TheTVDB",
"RemovedSeriesSingleRemovedHealthCheckMessage": "Series {0} was removed from TheTVDB",
"RootFolder": "Root Folder",
"RootFolderMissingHealthCheckMessage": "Missing root folder: {0}",
"RootFolderMultipleMissingHealthCheckMessage": "Multiple root folders are missing: {0}",
"SearchForMonitoredEpisodes": "Search for monitored episodes",
"ShowAdvanced": "Show Advanced",
"ShownClickToHide": "Shown, click to hide",
"SizeOnDisk": "Size on disk",
"SystemTimeHealthCheckMessage": "System time is off by more than 1 day. Scheduled tasks may not run correctly until the time is corrected",
"UI Language": "UI Language",
"Unmonitored": "Unmonitored"
"Unmonitored": "Unmonitored",
"UpdateAvailableHealthCheckMessage": "New update is available",
"UpdateStartupNotWritableHealthCheckMessage": "Cannot install update because startup folder '{0}' is not writable by the user '{1}'.",
"UpdateStartupTranslocationHealthCheckMessage": "Cannot install update because startup folder '{0}' is in an App Translocation folder.",
"UpdateUINotWritableHealthCheckMessage": "Cannot install update because UI folder '{0}' is not writable by the user '{1}'."
}