Fixed: Sabnzbd/Nzbget settings will now fail to save if you entered a non-existing category.
This commit is contained in:
parent
e3d0d25da7
commit
8967f59f35
|
@ -266,9 +266,18 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||||
return _proxy.GetVersion(Settings);
|
return _proxy.GetVersion(Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Test()
|
public override void Test(NzbgetSettings settings)
|
||||||
{
|
{
|
||||||
_proxy.GetVersion(Settings);
|
_proxy.GetVersion(settings);
|
||||||
|
|
||||||
|
var config = _proxy.GetConfig(settings);
|
||||||
|
|
||||||
|
var categories = GetCategories(config);
|
||||||
|
|
||||||
|
if (!categories.Any(v => v.Name == settings.TvCategory))
|
||||||
|
{
|
||||||
|
throw new ApplicationException("Category does not exist");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(TestNzbgetCommand message)
|
public void Execute(TestNzbgetCommand message)
|
||||||
|
@ -276,7 +285,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||||
var settings = new NzbgetSettings();
|
var settings = new NzbgetSettings();
|
||||||
settings.InjectFrom(message);
|
settings.InjectFrom(message);
|
||||||
|
|
||||||
_proxy.GetVersion(settings);
|
Test(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Javascript doesn't support 64 bit integers natively so json officially doesn't either.
|
// Javascript doesn't support 64 bit integers natively so json officially doesn't either.
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||||
var request = BuildRequest(new JsonRequest("append", parameters));
|
var request = BuildRequest(new JsonRequest("append", parameters));
|
||||||
|
|
||||||
var response = Json.Deserialize<NzbgetResponse<Boolean>>(ProcessRequest(request, settings));
|
var response = Json.Deserialize<NzbgetResponse<Boolean>>(ProcessRequest(request, settings));
|
||||||
_logger.Debug("Queue Response: [{0}]", response.Result);
|
_logger.Trace("Response: [{0}]", response.Result);
|
||||||
|
|
||||||
if (!response.Result)
|
if (!response.Result)
|
||||||
{
|
{
|
||||||
|
@ -154,7 +154,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||||
{
|
{
|
||||||
var client = BuildClient(settings);
|
var client = BuildClient(settings);
|
||||||
var response = client.Execute(restRequest);
|
var response = client.Execute(restRequest);
|
||||||
_logger.Debug("Response: {0}", response.Content);
|
_logger.Trace("Response: {0}", response.Content);
|
||||||
|
|
||||||
CheckForError(response);
|
CheckForError(response);
|
||||||
|
|
||||||
|
@ -170,6 +170,8 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||||
settings.Host,
|
settings.Host,
|
||||||
settings.Port);
|
settings.Port);
|
||||||
|
|
||||||
|
_logger.Debug("Url: " + url);
|
||||||
|
|
||||||
var client = new RestClient(url);
|
var client = new RestClient(url);
|
||||||
client.Authenticator = new HttpBasicAuthenticator(settings.Username, settings.Password);
|
client.Authenticator = new HttpBasicAuthenticator(settings.Username, settings.Password);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Organizer;
|
using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using Omu.ValueInjecter;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download.Clients.Pneumatic
|
namespace NzbDrone.Core.Download.Clients.Pneumatic
|
||||||
{
|
{
|
||||||
|
@ -100,12 +101,12 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Test()
|
public override void Test(PneumaticSettings settings)
|
||||||
{
|
{
|
||||||
PerformTest(Settings.NzbFolder);
|
PerformWriteTest(settings.NzbFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PerformTest(string folder)
|
private void PerformWriteTest(string folder)
|
||||||
{
|
{
|
||||||
var testPath = Path.Combine(folder, "drone_test.txt");
|
var testPath = Path.Combine(folder, "drone_test.txt");
|
||||||
_diskProvider.WriteAllText(testPath, DateTime.Now.ToString());
|
_diskProvider.WriteAllText(testPath, DateTime.Now.ToString());
|
||||||
|
@ -114,7 +115,10 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
|
||||||
|
|
||||||
public void Execute(TestPneumaticCommand message)
|
public void Execute(TestPneumaticCommand message)
|
||||||
{
|
{
|
||||||
PerformTest(message.Folder);
|
var settings = new PneumaticSettings();
|
||||||
|
settings.InjectFrom(message);
|
||||||
|
|
||||||
|
Test(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,9 +218,14 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Test()
|
public override void Test(SabnzbdSettings settings)
|
||||||
{
|
{
|
||||||
_proxy.GetCategories(Settings);
|
var categories = _proxy.GetCategories(settings);
|
||||||
|
|
||||||
|
if (!categories.Any(v => v == settings.TvCategory))
|
||||||
|
{
|
||||||
|
throw new ApplicationException("Category does not exist");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(TestSabnzbdCommand message)
|
public void Execute(TestSabnzbdCommand message)
|
||||||
|
@ -228,7 +233,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
var settings = new SabnzbdSettings();
|
var settings = new SabnzbdSettings();
|
||||||
settings.InjectFrom(message);
|
settings.InjectFrom(message);
|
||||||
|
|
||||||
_proxy.GetCategories(settings);
|
Test(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
|
@ -16,7 +18,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
void RemoveFrom(string source, string id, SabnzbdSettings settings);
|
void RemoveFrom(string source, string id, SabnzbdSettings settings);
|
||||||
string ProcessRequest(IRestRequest restRequest, string action, SabnzbdSettings settings);
|
string ProcessRequest(IRestRequest restRequest, string action, SabnzbdSettings settings);
|
||||||
SabnzbdVersionResponse GetVersion(SabnzbdSettings settings);
|
SabnzbdVersionResponse GetVersion(SabnzbdSettings settings);
|
||||||
SabnzbdCategoryResponse GetCategories(SabnzbdSettings settings);
|
List<String> GetCategories(SabnzbdSettings settings);
|
||||||
SabnzbdQueue GetQueue(int start, int limit, SabnzbdSettings settings);
|
SabnzbdQueue GetQueue(int start, int limit, SabnzbdSettings settings);
|
||||||
SabnzbdHistory GetHistory(int start, int limit, SabnzbdSettings settings);
|
SabnzbdHistory GetHistory(int start, int limit, SabnzbdSettings settings);
|
||||||
void RetryDownload(string id, SabnzbdSettings settings);
|
void RetryDownload(string id, SabnzbdSettings settings);
|
||||||
|
@ -83,12 +85,12 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SabnzbdCategoryResponse GetCategories(SabnzbdSettings settings)
|
public List<String> GetCategories(SabnzbdSettings settings)
|
||||||
{
|
{
|
||||||
var request = new RestRequest();
|
var request = new RestRequest();
|
||||||
var action = "mode=get_cats";
|
var action = "mode=get_cats";
|
||||||
|
|
||||||
var response = Json.Deserialize<SabnzbdCategoryResponse>(ProcessRequest(request, action, settings));
|
var response = Json.Deserialize<SabnzbdCategoryResponse>(ProcessRequest(request, action, settings)).Categories;
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +136,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||||
action,
|
action,
|
||||||
authentication);
|
authentication);
|
||||||
|
|
||||||
_logger.Debug(url);
|
_logger.Debug("Url: " + url);
|
||||||
|
|
||||||
return new RestClient(url);
|
return new RestClient(url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ using NzbDrone.Core.Organizer;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using Omu.ValueInjecter;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Download.Clients.UsenetBlackhole
|
namespace NzbDrone.Core.Download.Clients.UsenetBlackhole
|
||||||
{
|
{
|
||||||
|
@ -136,12 +137,6 @@ namespace NzbDrone.Core.Download.Clients.UsenetBlackhole
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Test()
|
|
||||||
{
|
|
||||||
PerformTest(Settings.NzbFolder);
|
|
||||||
PerformTest(Settings.WatchFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override DownloadClientStatus GetStatus()
|
public override DownloadClientStatus GetStatus()
|
||||||
{
|
{
|
||||||
return new DownloadClientStatus
|
return new DownloadClientStatus
|
||||||
|
@ -151,7 +146,13 @@ namespace NzbDrone.Core.Download.Clients.UsenetBlackhole
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PerformTest(string folder)
|
public override void Test(UsenetBlackholeSettings settings)
|
||||||
|
{
|
||||||
|
PerformWriteTest(settings.NzbFolder);
|
||||||
|
PerformWriteTest(settings.WatchFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PerformWriteTest(string folder)
|
||||||
{
|
{
|
||||||
var testPath = Path.Combine(folder, "drone_test.txt");
|
var testPath = Path.Combine(folder, "drone_test.txt");
|
||||||
_diskProvider.WriteAllText(testPath, DateTime.Now.ToString());
|
_diskProvider.WriteAllText(testPath, DateTime.Now.ToString());
|
||||||
|
@ -160,8 +161,10 @@ namespace NzbDrone.Core.Download.Clients.UsenetBlackhole
|
||||||
|
|
||||||
public void Execute(TestUsenetBlackholeCommand message)
|
public void Execute(TestUsenetBlackholeCommand message)
|
||||||
{
|
{
|
||||||
PerformTest(message.NzbFolder);
|
var settings = new UsenetBlackholeSettings();
|
||||||
PerformTest(message.WatchFolder);
|
settings.InjectFrom(message);
|
||||||
|
|
||||||
|
Test(settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,10 @@ namespace NzbDrone.Core.Download
|
||||||
public abstract IEnumerable<DownloadClientItem> GetItems();
|
public abstract IEnumerable<DownloadClientItem> GetItems();
|
||||||
public abstract void RemoveItem(string id);
|
public abstract void RemoveItem(string id);
|
||||||
public abstract void RetryDownload(string id);
|
public abstract void RetryDownload(string id);
|
||||||
public abstract void Test();
|
|
||||||
public abstract DownloadClientStatus GetStatus();
|
public abstract DownloadClientStatus GetStatus();
|
||||||
|
|
||||||
|
public abstract void Test(TSettings settings);
|
||||||
|
|
||||||
protected RemoteEpisode GetRemoteEpisode(String title)
|
protected RemoteEpisode GetRemoteEpisode(String title)
|
||||||
{
|
{
|
||||||
var parsedEpisodeInfo = Parser.Parser.ParseTitle(title);
|
var parsedEpisodeInfo = Parser.Parser.ParseTitle(title);
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace NzbDrone.Core.Download
|
||||||
IEnumerable<DownloadClientItem> GetItems();
|
IEnumerable<DownloadClientItem> GetItems();
|
||||||
void RemoveItem(string id);
|
void RemoveItem(string id);
|
||||||
void RetryDownload(string id);
|
void RetryDownload(string id);
|
||||||
void Test();
|
|
||||||
|
|
||||||
DownloadClientStatus GetStatus();
|
DownloadClientStatus GetStatus();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue