1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-21 22:05:43 -04:00

Fixed: Sabnzbd now verifies the category configuration.

This commit is contained in:
Taloth Saldono
2014-07-04 22:27:21 +02:00
parent 6941888832
commit 232a2b9422
10 changed files with 194 additions and 58 deletions
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using FluentValidation.Results;
using NzbDrone.Common.Disk;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
@@ -14,7 +15,8 @@ namespace NzbDrone.Core.Download
where TSettings : IProviderConfig, new()
{
protected readonly IConfigService _configService;
private readonly IParsingService _parsingService;
protected readonly IDiskProvider _diskProvider;
protected readonly IParsingService _parsingService;
protected readonly Logger _logger;
public Type ConfigContract
@@ -44,9 +46,10 @@ namespace NzbDrone.Core.Download
}
}
protected DownloadClientBase(IConfigService configService, IParsingService parsingService, Logger logger)
protected DownloadClientBase(IConfigService configService, IDiskProvider diskProvider, IParsingService parsingService, Logger logger)
{
_configService = configService;
_diskProvider = diskProvider;
_parsingService = parsingService;
_logger = logger;
}
@@ -77,5 +80,30 @@ namespace NzbDrone.Core.Download
return remoteEpisode;
}
protected ValidationFailure TestFolder(String folder, String propertyName, Boolean mustBeWritable = true)
{
if (!_diskProvider.FolderExists(folder))
{
return new ValidationFailure(propertyName, "Folder does not exist");
}
if (mustBeWritable)
{
try
{
var testPath = Path.Combine(folder, "drone_test.txt");
_diskProvider.WriteAllText(testPath, DateTime.Now.ToString());
_diskProvider.DeleteFile(testPath);
}
catch (Exception ex)
{
_logger.ErrorException(ex.Message, ex);
return new ValidationFailure(propertyName, "Unable to write to folder");
}
}
return null;
}
}
}