mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-31 12:10:19 -07:00
Fixed: Error updating providers with ID missing from JSON
(cherry picked from commit c435fcd685cc97e98d14f747227eefd39e4d1164)
This commit is contained in:
parent
bd7d25f963
commit
9850823298
1 changed files with 10 additions and 3 deletions
|
@ -86,9 +86,16 @@ namespace Lidarr.Api.V1
|
||||||
[RestPutById]
|
[RestPutById]
|
||||||
[Consumes("application/json")]
|
[Consumes("application/json")]
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
public ActionResult<TProviderResource> UpdateProvider([FromBody] TProviderResource providerResource, [FromQuery] bool forceSave = false)
|
public ActionResult<TProviderResource> UpdateProvider([FromRoute] int id, [FromBody] TProviderResource providerResource, [FromQuery] bool forceSave = false)
|
||||||
{
|
{
|
||||||
var existingDefinition = _providerFactory.Find(providerResource.Id);
|
// TODO: Remove fallback to Id from body in next API version bump
|
||||||
|
var existingDefinition = _providerFactory.Find(id) ?? _providerFactory.Find(providerResource.Id);
|
||||||
|
|
||||||
|
if (existingDefinition == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
var providerDefinition = GetDefinition(providerResource, existingDefinition, true, !forceSave, false);
|
var providerDefinition = GetDefinition(providerResource, existingDefinition, true, !forceSave, false);
|
||||||
|
|
||||||
// Comparing via JSON string to eliminate the need for every provider implementation to implement equality checks.
|
// Comparing via JSON string to eliminate the need for every provider implementation to implement equality checks.
|
||||||
|
@ -107,7 +114,7 @@ namespace Lidarr.Api.V1
|
||||||
_providerFactory.Update(providerDefinition);
|
_providerFactory.Update(providerDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Accepted(providerResource.Id);
|
return Accepted(existingDefinition.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("bulk")]
|
[HttpPut("bulk")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue