1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-23 22:25:56 -04:00

Implement equality checks for providers

This commit is contained in:
Bogdan
2024-04-14 07:16:26 +03:00
committed by Mark McDowall
parent 536ff142c3
commit 084fcc2295
84 changed files with 517 additions and 312 deletions
+1 -3
View File
@@ -90,10 +90,8 @@ namespace Sonarr.Api.V3
var existingDefinition = _providerFactory.Find(providerResource.Id);
var providerDefinition = GetDefinition(providerResource, existingDefinition, true, !forceSave, false);
// Comparing via JSON string to eliminate the need for every provider implementation to implement equality checks.
// Compare settings separately because they are not serialized with the definition.
var hasDefinitionChanged = STJson.ToJson(existingDefinition) != STJson.ToJson(providerDefinition) ||
STJson.ToJson(existingDefinition.Settings) != STJson.ToJson(providerDefinition.Settings);
var hasDefinitionChanged = !existingDefinition.Equals(providerDefinition) || !existingDefinition.Settings.Equals(providerDefinition.Settings);
// Only test existing definitions if it is enabled and forceSave isn't set and the definition has changed.
if (providerDefinition.Enable && !forceSave && hasDefinitionChanged)