diff --git a/CHANGELOG.md b/CHANGELOG.md index a90b3a0a..dfd7aef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Crash when doing `recyclarr sync` with no `reset_unmatched_scores` present. + ## [5.3.0] - 2023-08-21 ### Added diff --git a/src/Recyclarr.TrashLib/Config/Parsing/ConfigYamlMapperProfile.cs b/src/Recyclarr.TrashLib/Config/Parsing/ConfigYamlMapperProfile.cs index a13bab1b..ba311f74 100644 --- a/src/Recyclarr.TrashLib/Config/Parsing/ConfigYamlMapperProfile.cs +++ b/src/Recyclarr.TrashLib/Config/Parsing/ConfigYamlMapperProfile.cs @@ -23,7 +23,8 @@ public class ConfigYamlMapperProfile : Profile .ForMember(x => x.UpgradeAllowed, o => o.MapFrom(x => x.Upgrade!.Allowed)) .ForMember(x => x.UpgradeUntilQuality, o => o.MapFrom(x => x.Upgrade!.UntilQuality)) .ForMember(x => x.UpgradeUntilScore, o => o.MapFrom(x => x.Upgrade!.UntilScore)) - .ForMember(x => x.QualitySort, o => o.NullSubstitute(QualitySortAlgorithm.Top)); + .ForMember(x => x.QualitySort, o => o.NullSubstitute(QualitySortAlgorithm.Top)) + .ForMember(x => x.ResetUnmatchedScores, o => o.UseDestinationValue()); CreateMap() .ForMember(x => x.InstanceName, o => o.Ignore()); diff --git a/src/tests/Recyclarr.Cli.Tests/AutoMapperConfigurationTest.cs b/src/tests/Recyclarr.Cli.Tests/AutoMapperConfigurationTest.cs index dec620ad..152bc304 100644 --- a/src/tests/Recyclarr.Cli.Tests/AutoMapperConfigurationTest.cs +++ b/src/tests/Recyclarr.Cli.Tests/AutoMapperConfigurationTest.cs @@ -11,6 +11,9 @@ public class AutoMapperConfigurationTest : CliIntegrationFixture public void Automapper_config_is_valid() { var mapper = Resolve(); + // Build an execution plan like: + // var plan = mapper.BuildExecutionPlan(typeof(QualityProfileConfigYaml), typeof(QualityProfileConfig)); + // And do `plan.ToReadableString()` in the Debug Expressions/Watch mapper.AssertConfigurationIsValid(); } } diff --git a/src/tests/Recyclarr.TrashLib.Tests/Config/Parsing/ConfigYamlMapperProfileTest.cs b/src/tests/Recyclarr.TrashLib.Tests/Config/Parsing/ConfigYamlMapperProfileTest.cs index 542e46c1..517b9d51 100644 --- a/src/tests/Recyclarr.TrashLib.Tests/Config/Parsing/ConfigYamlMapperProfileTest.cs +++ b/src/tests/Recyclarr.TrashLib.Tests/Config/Parsing/ConfigYamlMapperProfileTest.cs @@ -41,4 +41,15 @@ public class ConfigYamlMapperProfileTest result.QualitySort.Should().Be(QualitySortAlgorithm.Top); } + + [Test] + public void Non_null_reset_unmatched_scores_when_source_is_null() + { + var yaml = new QualityProfileConfigYaml(); + + var mapper = CreateMapper(); + var result = mapper.Map(yaml); + + result.ResetUnmatchedScores.Should().BeEquivalentTo(new ResetUnmatchedScoresConfig()); + } }