diff --git a/src/NzbDrone.Core/HealthCheck/Checks/ImportListRootFolderCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/ImportListRootFolderCheck.cs index 599ed391e..300564708 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/ImportListRootFolderCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/ImportListRootFolderCheck.cs @@ -2,15 +2,19 @@ using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Datastore.Events; using NzbDrone.Core.ImportLists; using NzbDrone.Core.Localization; using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Movies.Events; +using NzbDrone.Core.RootFolders; using NzbDrone.Core.ThingiProvider.Events; namespace NzbDrone.Core.HealthCheck.Checks { [CheckOn(typeof(ProviderUpdatedEvent))] + [CheckOn(typeof(ProviderDeletedEvent))] + [CheckOn(typeof(ModelEvent))] [CheckOn(typeof(MoviesDeletedEvent))] [CheckOn(typeof(MovieMovedEvent))] [CheckOn(typeof(MovieFileImportedEvent), CheckOnCondition.FailedOnly)] @@ -19,17 +23,21 @@ namespace NzbDrone.Core.HealthCheck.Checks { private readonly IImportListFactory _importListFactory; private readonly IDiskProvider _diskProvider; + private readonly IRootFolderService _rootFolderService; - public ImportListRootFolderCheck(IImportListFactory importListFactory, IDiskProvider diskProvider, ILocalizationService localizationService) + public ImportListRootFolderCheck(IImportListFactory importListFactory, IDiskProvider diskProvider, IRootFolderService rootFolderService, ILocalizationService localizationService) : base(localizationService) { _importListFactory = importListFactory; _diskProvider = diskProvider; + _rootFolderService = rootFolderService; } public override HealthCheck Check() { var importLists = _importListFactory.All(); + var rootFolders = _rootFolderService.All(); + var missingRootFolders = new Dictionary>(); foreach (var importList in importLists) @@ -43,7 +51,10 @@ namespace NzbDrone.Core.HealthCheck.Checks continue; } - if (rootFolderPath.IsNullOrWhiteSpace() || !_diskProvider.FolderExists(rootFolderPath)) + if (rootFolderPath.IsNullOrWhiteSpace() || + !rootFolderPath.IsPathValid(PathValidationType.CurrentOs) || + !rootFolders.Any(r => r.Path.PathEquals(rootFolderPath)) || + !_diskProvider.FolderExists(rootFolderPath)) { missingRootFolders.Add(rootFolderPath, new List { importList }); } diff --git a/src/NzbDrone.Core/HealthCheck/Checks/MovieCollectionRootFolderCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/MovieCollectionRootFolderCheck.cs index 4adb4f96e..58524c45c 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/MovieCollectionRootFolderCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/MovieCollectionRootFolderCheck.cs @@ -18,17 +18,21 @@ namespace NzbDrone.Core.HealthCheck.Checks { private readonly IMovieCollectionService _collectionService; private readonly IDiskProvider _diskProvider; + private readonly IRootFolderService _rootFolderService; - public MovieCollectionRootFolderCheck(IMovieCollectionService collectionService, IDiskProvider diskProvider, ILocalizationService localizationService) + public MovieCollectionRootFolderCheck(IMovieCollectionService collectionService, IDiskProvider diskProvider, IRootFolderService rootFolderService, ILocalizationService localizationService) : base(localizationService) { _collectionService = collectionService; _diskProvider = diskProvider; + _rootFolderService = rootFolderService; } public override HealthCheck Check() { var collections = _collectionService.GetAllCollections(); + var rootFolders = _rootFolderService.All(); + var missingRootFolders = new Dictionary>(); foreach (var collection in collections) @@ -42,7 +46,10 @@ namespace NzbDrone.Core.HealthCheck.Checks continue; } - if (rootFolderPath.IsNullOrWhiteSpace() || !rootFolderPath.IsPathValid(PathValidationType.CurrentOs) || !_diskProvider.FolderExists(rootFolderPath)) + if (rootFolderPath.IsNullOrWhiteSpace() || + !rootFolderPath.IsPathValid(PathValidationType.CurrentOs) || + !rootFolders.Any(r => r.Path.PathEquals(rootFolderPath)) || + !_diskProvider.FolderExists(rootFolderPath)) { missingRootFolders.Add(rootFolderPath, new List { collection }); }