mirror of
https://github.com/Readarr/Readarr
synced 2026-02-09 16:21:47 +01:00
Fixed: Validation when testing indexers, import lists, connections and download clients
Fixes #1612 Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
parent
c5c2b94b9a
commit
599f52e72f
7 changed files with 11 additions and 60 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
|
|
@ -24,7 +24,8 @@ public static List<string> GetSystemFolders()
|
|||
"/boot",
|
||||
"/lib",
|
||||
"/sbin",
|
||||
"/proc"
|
||||
"/proc",
|
||||
"/usr/bin"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,5 @@ public DownloadClientController(IDownloadClientFactory downloadClientFactory)
|
|||
: base(downloadClientFactory, "downloadclient", ResourceMapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Validate(DownloadClientDefinition definition, bool includeWarnings)
|
||||
{
|
||||
if (!definition.Enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Validate(definition, includeWarnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,15 +22,5 @@ public ImportListController(IImportListFactory importListFactory,
|
|||
SharedValidator.RuleFor(c => c.QualityProfileId).SetValidator(qualityProfileExistsValidator);
|
||||
SharedValidator.RuleFor(c => c.MetadataProfileId).SetValidator(metadataProfileExistsValidator);
|
||||
}
|
||||
|
||||
protected override void Validate(ImportListDefinition definition, bool includeWarnings)
|
||||
{
|
||||
if (!definition.Enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Validate(definition, includeWarnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,5 @@ public IndexerController(IndexerFactory indexerFactory)
|
|||
: base(indexerFactory, "indexer", ResourceMapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Validate(IndexerDefinition definition, bool includeWarnings)
|
||||
{
|
||||
if (!definition.Enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Validate(definition, includeWarnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,5 @@ public MetadataController(IMetadataFactory metadataFactory)
|
|||
: base(metadataFactory, "metadata", ResourceMapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Validate(MetadataDefinition definition, bool includeWarnings)
|
||||
{
|
||||
if (!definition.Enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Validate(definition, includeWarnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,5 @@ public NotificationController(NotificationFactory notificationFactory)
|
|||
: base(notificationFactory, "notification", ResourceMapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Validate(NotificationDefinition definition, bool includeWarnings)
|
||||
{
|
||||
if (!definition.Enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Validate(definition, includeWarnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public List<TProviderResource> GetAll()
|
|||
[RestPostById]
|
||||
public ActionResult<TProviderResource> CreateProvider(TProviderResource providerResource)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, false);
|
||||
var providerDefinition = GetDefinition(providerResource, true, false, false);
|
||||
|
||||
if (providerDefinition.Enable)
|
||||
{
|
||||
|
|
@ -75,8 +75,8 @@ public ActionResult<TProviderResource> CreateProvider(TProviderResource provider
|
|||
[RestPutById]
|
||||
public ActionResult<TProviderResource> UpdateProvider(TProviderResource providerResource)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, false);
|
||||
var existingDefinition = _providerFactory.Get(providerDefinition.Id);
|
||||
var providerDefinition = GetDefinition(providerResource, true, false, false);
|
||||
var forceSave = Request.GetBooleanQueryParameter("forceSave");
|
||||
|
||||
// Only test existing definitions if it was previously disabled
|
||||
if (providerDefinition.Enable && !existingDefinition.Enable)
|
||||
|
|
@ -89,11 +89,11 @@ public ActionResult<TProviderResource> UpdateProvider(TProviderResource provider
|
|||
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);
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ public List<TProviderResource> GetTemplates()
|
|||
[HttpPost("test")]
|
||||
public object Test([FromBody] TProviderResource providerResource)
|
||||
{
|
||||
var providerDefinition = GetDefinition(providerResource, true);
|
||||
var providerDefinition = GetDefinition(providerResource, true, true, true);
|
||||
|
||||
Test(providerDefinition, true);
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ public IActionResult TestAll()
|
|||
[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());
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ public IActionResult RequestAction(string name, [FromBody] TProviderResource res
|
|||
return Content(data.ToJson(), "application/json");
|
||||
}
|
||||
|
||||
protected virtual void Validate(TProviderDefinition definition, bool includeWarnings)
|
||||
private void Validate(TProviderDefinition definition, bool includeWarnings)
|
||||
{
|
||||
var validationResult = definition.Settings.Validate();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue