mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-22 07:42:28 +00: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 @@ public ActionResult<TProviderResource> CreateProvider([FromBody] TProviderResour
|
|||
[RestPutById]
|
||||
[Consumes("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);
|
||||
|
||||
// Comparing via JSON string to eliminate the need for every provider implementation to implement equality checks.
|
||||
|
@ -107,7 +114,7 @@ public ActionResult<TProviderResource> UpdateProvider([FromBody] TProviderResour
|
|||
_providerFactory.Update(providerDefinition);
|
||||
}
|
||||
|
||||
return Accepted(providerResource.Id);
|
||||
return Accepted(existingDefinition.Id);
|
||||
}
|
||||
|
||||
[HttpPut("bulk")]
|
||||
|
|
Loading…
Reference in a new issue