mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-21 23:32:27 +00:00
Fixed: Root folder existence for import lists health check
Closes #5218
This commit is contained in:
parent
23f7dc3d3c
commit
29d17c6347
1 changed files with 13 additions and 2 deletions
|
@ -1,15 +1,19 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Datastore.Events;
|
using NzbDrone.Core.Datastore.Events;
|
||||||
using NzbDrone.Core.ImportLists;
|
using NzbDrone.Core.ImportLists;
|
||||||
using NzbDrone.Core.Localization;
|
using NzbDrone.Core.Localization;
|
||||||
using NzbDrone.Core.MediaFiles.Events;
|
using NzbDrone.Core.MediaFiles.Events;
|
||||||
using NzbDrone.Core.Music.Events;
|
using NzbDrone.Core.Music.Events;
|
||||||
using NzbDrone.Core.RootFolders;
|
using NzbDrone.Core.RootFolders;
|
||||||
|
using NzbDrone.Core.ThingiProvider.Events;
|
||||||
|
|
||||||
namespace NzbDrone.Core.HealthCheck.Checks
|
namespace NzbDrone.Core.HealthCheck.Checks
|
||||||
{
|
{
|
||||||
|
[CheckOn(typeof(ProviderUpdatedEvent<IImportList>))]
|
||||||
|
[CheckOn(typeof(ProviderDeletedEvent<IImportList>))]
|
||||||
[CheckOn(typeof(ModelEvent<RootFolder>))]
|
[CheckOn(typeof(ModelEvent<RootFolder>))]
|
||||||
[CheckOn(typeof(ArtistsDeletedEvent))]
|
[CheckOn(typeof(ArtistsDeletedEvent))]
|
||||||
[CheckOn(typeof(ArtistMovedEvent))]
|
[CheckOn(typeof(ArtistMovedEvent))]
|
||||||
|
@ -19,17 +23,21 @@ public class ImportListRootFolderCheck : HealthCheckBase
|
||||||
{
|
{
|
||||||
private readonly IImportListFactory _importListFactory;
|
private readonly IImportListFactory _importListFactory;
|
||||||
private readonly IDiskProvider _diskProvider;
|
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)
|
: base(localizationService)
|
||||||
{
|
{
|
||||||
_importListFactory = importListFactory;
|
_importListFactory = importListFactory;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
|
_rootFolderService = rootFolderService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override HealthCheck Check()
|
public override HealthCheck Check()
|
||||||
{
|
{
|
||||||
var importLists = _importListFactory.All();
|
var importLists = _importListFactory.All();
|
||||||
|
var rootFolders = _rootFolderService.All();
|
||||||
|
|
||||||
var missingRootFolders = new Dictionary<string, List<ImportListDefinition>>();
|
var missingRootFolders = new Dictionary<string, List<ImportListDefinition>>();
|
||||||
|
|
||||||
foreach (var importList in importLists)
|
foreach (var importList in importLists)
|
||||||
|
@ -43,7 +51,10 @@ public override HealthCheck Check()
|
||||||
continue;
|
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 });
|
missingRootFolders.Add(rootFolderPath, new List<ImportListDefinition> { importList });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue