1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-10 13:02:47 +01:00

Roto folder fixes

New: Health check for missing series root folders
Fixed: Do not remove episodes from series when root folder is missing
This commit is contained in:
Mark McDowall 2014-05-25 22:14:15 -07:00
parent 1b10002ed8
commit 48ac09baae
4 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,49 @@
using System;
using System.Linq;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.HealthCheck.Checks
{
public class RootFolderCheck : HealthCheckBase
{
private readonly ISeriesService _seriesService;
private readonly IDiskProvider _diskProvider;
public RootFolderCheck(ISeriesService seriesService, IDiskProvider diskProvider)
{
_seriesService = seriesService;
_diskProvider = diskProvider;
}
public override HealthCheck Check()
{
var missingRootFolders = _seriesService.GetAllSeries()
.Select(s => _diskProvider.GetParentFolder(s.Path))
.Distinct()
.Where(s => !_diskProvider.FolderExists(s))
.ToList();
if (missingRootFolders.Any())
{
if (missingRootFolders.Count == 1)
{
return new HealthCheck(GetType(), HealthCheckResult.Error, "Missing root folder: " + missingRootFolders.First());
}
var message = String.Format("Multiple root folders are missing: {0}", String.Join(" | ", missingRootFolders));
return new HealthCheck(GetType(), HealthCheckResult.Error, message);
}
return new HealthCheck(GetType());
}
public override bool CheckOnConfigChange
{
get
{
return false;
}
}
}
}

View File

@ -22,6 +22,7 @@ public UpdateCheck(IDiskProvider diskProvider, IAppFolderInfo appFolderInfo, ICh
public override HealthCheck Check() public override HealthCheck Check()
{ {
//TODO: Check on mono as well
if (OsInfo.IsWindows) if (OsInfo.IsWindows)
{ {
try try

View File

@ -58,13 +58,21 @@ public DiskScanService(IDiskProvider diskProvider,
public void Scan(Series series) public void Scan(Series series)
{ {
var rootFolder = _diskProvider.GetParentFolder(series.Path);
if (!_diskProvider.FolderExists(rootFolder))
{
_logger.Warn("Series' root folder ({0}) doesn't exist.", rootFolder);
return;
}
_logger.ProgressInfo("Scanning disk for {0}", series.Title); _logger.ProgressInfo("Scanning disk for {0}", series.Title);
_commandExecutor.PublishCommand(new CleanMediaFileDb(series.Id)); _commandExecutor.PublishCommand(new CleanMediaFileDb(series.Id));
if (!_diskProvider.FolderExists(series.Path)) if (!_diskProvider.FolderExists(series.Path))
{ {
if (_configService.CreateEmptySeriesFolders && if (_configService.CreateEmptySeriesFolders &&
_diskProvider.FolderExists(_diskProvider.GetParentFolder(series.Path))) _diskProvider.FolderExists(rootFolder))
{ {
_logger.Debug("Creating missing series folder: {0}", series.Path); _logger.Debug("Creating missing series folder: {0}", series.Path);
_diskProvider.CreateFolder(series.Path); _diskProvider.CreateFolder(series.Path);

View File

@ -281,6 +281,7 @@
<Compile Include="HealthCheck\Checks\MonoVersionCheck.cs" /> <Compile Include="HealthCheck\Checks\MonoVersionCheck.cs" />
<Compile Include="HealthCheck\Checks\DroneFactoryCheck.cs" /> <Compile Include="HealthCheck\Checks\DroneFactoryCheck.cs" />
<Compile Include="HealthCheck\Checks\IndexerCheck.cs" /> <Compile Include="HealthCheck\Checks\IndexerCheck.cs" />
<Compile Include="HealthCheck\Checks\RootFolderCheck.cs" />
<Compile Include="HealthCheck\Checks\UpdateCheck.cs" /> <Compile Include="HealthCheck\Checks\UpdateCheck.cs" />
<Compile Include="HealthCheck\HealthCheck.cs" /> <Compile Include="HealthCheck\HealthCheck.cs" />
<Compile Include="HealthCheck\HealthCheckBase.cs" /> <Compile Include="HealthCheck\HealthCheckBase.cs" />