mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-02-02 11:34:39 +02:00
Fixed: Root folder existence for import lists health check
This commit is contained in:
parent
8d4ba77b12
commit
832de3e75e
@ -1,13 +1,20 @@
|
||||
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.RootFolders;
|
||||
using NzbDrone.Core.ThingiProvider.Events;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
[CheckOn(typeof(ProviderUpdatedEvent<IImportList>))]
|
||||
[CheckOn(typeof(ProviderDeletedEvent<IImportList>))]
|
||||
[CheckOn(typeof(ModelEvent<RootFolder>))]
|
||||
[CheckOn(typeof(SeriesDeletedEvent))]
|
||||
[CheckOn(typeof(SeriesMovedEvent))]
|
||||
[CheckOn(typeof(EpisodeImportedEvent), CheckOnCondition.FailedOnly)]
|
||||
@ -16,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<string, List<ImportListDefinition>>();
|
||||
|
||||
foreach (var importList in importLists)
|
||||
@ -40,7 +51,10 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_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<ImportListDefinition> { importList });
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user