diff --git a/CHANGELOG.md b/CHANGELOG.md index 43660df3..0cba0d52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Remove unredacted request URI from log files on exception +- Remove unredacted request URI from log files on exception. +- Scores/Custom Formats would not sync under certain conditions (#160). ## [4.1.1] - 2023-01-06 diff --git a/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/JsonTransactionStepTest.cs b/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/JsonTransactionStepTest.cs index cdfac82f..849ac5bf 100644 --- a/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/JsonTransactionStepTest.cs +++ b/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/JsonTransactionStepTest.cs @@ -333,4 +333,27 @@ public class JsonTransactionStepTest expectedTransactions.ConflictingCustomFormats.Add(new ConflictingCustomFormat(guideCfs[0], 1)); processor.Transactions.Should().BeEquivalentTo(expectedTransactions); } + + [Test, AutoMockData] + public void Service_cf_id_set_when_no_cache_entry(JsonTransactionStep processor) + { + const string serviceCfData = @" +[{ + 'id': 1, + 'name': 'first' +}]"; + + var serviceCfs = JsonConvert.DeserializeObject>(serviceCfData)!; + + var guideCfs = new List + { + NewCf.Processed("first", "") + }; + + processor.Process(guideCfs, serviceCfs); + + processor.Transactions.UpdatedCustomFormats.Should().BeEquivalentTo( + new[] {NewCf.Processed("first", "", new TrashIdMapping("", "first", 1))}, + o => o.Including(x => x.CacheEntry!.CustomFormatId)); + } } diff --git a/src/Recyclarr.TrashLib/Services/CustomFormat/Processors/PersistenceSteps/JsonTransactionStep.cs b/src/Recyclarr.TrashLib/Services/CustomFormat/Processors/PersistenceSteps/JsonTransactionStep.cs index e7269f23..16102abd 100644 --- a/src/Recyclarr.TrashLib/Services/CustomFormat/Processors/PersistenceSteps/JsonTransactionStep.cs +++ b/src/Recyclarr.TrashLib/Services/CustomFormat/Processors/PersistenceSteps/JsonTransactionStep.cs @@ -51,7 +51,7 @@ public class JsonTransactionStep : IJsonTransactionStep // Set the cache for use later (like updating scores) if it hasn't been updated already. // This handles CFs that already exist in the service but aren't cached (they will be added to cache // later). - guideCf.SetCache(guideCf.Json.Value("id")); + guideCf.SetCache(serviceCf.Value("id")); } guideCf.Json = (JObject) serviceCf.DeepClone();