@ -1,33 +1,33 @@
using System.Linq ;
using System.Linq ;
using NzbDrone.Common.Disk ;
using NzbDrone.Common.Disk ;
using NzbDrone.Common.Extensions ;
using NzbDrone.Common.Extensions ;
using NzbDrone.Core. Tv ;
using NzbDrone.Core. Music ;
namespace NzbDrone.Core.HealthCheck.Checks
namespace NzbDrone.Core.HealthCheck.Checks
{
{
public class MountCheck : HealthCheckBase
public class MountCheck : HealthCheckBase
{
{
private readonly IDiskProvider _diskProvider ;
private readonly IDiskProvider _diskProvider ;
private readonly I SeriesService _series Service;
private readonly I ArtistService _artist Service;
public MountCheck ( IDiskProvider diskProvider , I SeriesService series Service)
public MountCheck ( IDiskProvider diskProvider , I ArtistService artist Service)
{
{
_diskProvider = diskProvider ;
_diskProvider = diskProvider ;
_ seriesService = series Service;
_ artistService = artist Service;
}
}
public override HealthCheck Check ( )
public override HealthCheck Check ( )
{
{
// Not best for optimization but due to possible symlinks and junctions, we get mounts based on series path so internals can handle mount resolution.
// Not best for optimization but due to possible symlinks and junctions, we get mounts based on series path so internals can handle mount resolution.
var mounts = _seriesService . GetAllSeries ( )
var mounts = _artistService . GetAllArtists ( )
. Select ( series = > _diskProvider . GetMount ( series . Path ) )
. Select ( artist = > _diskProvider . GetMount ( artist . Path ) )
. Where ( m = > m ! = null & & m . MountOptions ! = null & & m . MountOptions . IsReadOnly )
. DistinctBy ( m = > m . RootDirectory )
. DistinctBy ( m = > m . RootDirectory )
. Where ( m = > m . MountOptions ! = null & & m . MountOptions . IsReadOnly )
. ToList ( ) ;
. ToList ( ) ;
if ( mounts . Any ( ) )
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 , "Mount containing a artist path is mounted read-only: " + string . Join ( "," , mounts . Select ( m = > m . Name ) ) , "# artist -mount-ro") ;
}
}
return new HealthCheck ( GetType ( ) ) ;
return new HealthCheck ( GetType ( ) ) ;