mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 22:07:32 -04:00
Fixed: Validation when testing indexers, connections and download clients
Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
69de6d18eb
commit
135efe6d94
5 changed files with 10 additions and 39 deletions
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
|
@ -24,7 +24,8 @@ namespace NzbDrone.Common.Disk
|
|||
"/boot",
|
||||
"/lib",
|
||||
"/sbin",
|
||||
"/proc"
|
||||
"/proc",
|
||||
"/usr/bin"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,15 +12,5 @@ namespace Prowlarr.Api.V1.DownloadClient
|
|||
: base(downloadClientFactory, "downloadclient", ResourceMapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Validate(DownloadClientDefinition definition, bool includeWarnings)
|
||||
{
|
||||
if (!definition.Enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Validate(definition, includeWarnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,5 @@ namespace Prowlarr.Api.V1.Indexers
|
|||
: base(indexerFactory, "indexer", resourceMapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Validate(IndexerDefinition definition, bool includeWarnings)
|
||||
{
|
||||
if (!definition.Enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Validate(definition, includeWarnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,15 +12,5 @@ namespace Prowlarr.Api.V1.Notifications
|
|||
: base(notificationFactory, "notification", ResourceMapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Validate(NotificationDefinition definition, bool includeWarnings)
|
||||
{
|
||||
if (!definition.OnHealthIssue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Validate(definition, includeWarnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace Prowlarr.Api.V1
|
|||
[Produces("application/json")]
|
||||
public ActionResult<TProviderResource> CreateProvider(TProviderResource providerResource)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, false);
|
||||
var providerDefinition = GetDefinition(providerResource, true, false, false);
|
||||
|
||||
if (providerDefinition.Enable)
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ namespace Prowlarr.Api.V1
|
|||
[Produces("application/json")]
|
||||
public ActionResult<TProviderResource> UpdateProvider(TProviderResource providerResource)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, false);
|
||||
var providerDefinition = GetDefinition(providerResource, true, false, false);
|
||||
var forceSave = Request.GetBooleanQueryParameter("forceSave");
|
||||
|
||||
// Only test existing definitions if it is enabled and forceSave isn't set.
|
||||
|
@ -92,11 +92,11 @@ namespace Prowlarr.Api.V1
|
|||
return Accepted(providerResource.Id);
|
||||
}
|
||||
|
||||
private TProviderDefinition GetDefinition(TProviderResource providerResource, bool includeWarnings = false, bool validate = true)
|
||||
private TProviderDefinition GetDefinition(TProviderResource providerResource, bool validate, bool includeWarnings, bool forceValidate)
|
||||
{
|
||||
var definition = _resourceMapper.ToModel(providerResource);
|
||||
|
||||
if (validate)
|
||||
if (validate && (definition.Enable || forceValidate))
|
||||
{
|
||||
Validate(definition, includeWarnings);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ namespace Prowlarr.Api.V1
|
|||
[HttpPost("test")]
|
||||
public object Test([FromBody] TProviderResource providerResource)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, true);
|
||||
var providerDefinition = GetDefinition(providerResource, true, true, true);
|
||||
|
||||
Test(providerDefinition, true);
|
||||
|
||||
|
@ -172,7 +172,7 @@ namespace Prowlarr.Api.V1
|
|||
[HttpPost("action/{name}")]
|
||||
public IActionResult RequestAction(string name, [FromBody] TProviderResource resource)
|
||||
{
|
||||
var providerDefinition = GetDefinition(resource, true, false);
|
||||
var providerDefinition = GetDefinition(resource, false, false, false);
|
||||
|
||||
var query = Request.Query.ToDictionary(x => x.Key, x => x.Value.ToString());
|
||||
|
||||
|
@ -181,7 +181,7 @@ namespace Prowlarr.Api.V1
|
|||
return Json(data);
|
||||
}
|
||||
|
||||
protected virtual void Validate(TProviderDefinition definition, bool includeWarnings)
|
||||
private void Validate(TProviderDefinition definition, bool includeWarnings)
|
||||
{
|
||||
var validationResult = definition.Settings.Validate();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue