mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-21 22:04:31 -04:00
Fixed: Sabnzbd now verifies the category configuration.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user