diff --git a/CHANGELOG.md b/CHANGELOG.md index f237c65f..aef9f2a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ changes you may need to make. - **BREAKING**: Array-style instances are no longer supported. - **BREAKING**: Remove deprecated CLI commands: `radarr`, `sonarr`, and `create-config`. +- **BREAKING**: Removed `reset_unmatched_scores` support under quality profile score section. ## [4.4.1] - 2023-04-08 diff --git a/src/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhaseTest.cs b/src/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhaseTest.cs index e2c6791d..fc51c80e 100644 --- a/src/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhaseTest.cs +++ b/src/Recyclarr.Cli.Tests/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhaseTest.cs @@ -11,101 +11,6 @@ namespace Recyclarr.Cli.Tests.Pipelines.QualityProfile.PipelinePhases; [Parallelizable(ParallelScope.All)] public class QualityProfileConfigPhaseTest { - [Test, AutoMockData] - public void Reset_unmatched_scores_promoted_to_quality_profiles_property_when_no_quality_profiles_in_config( - QualityProfileConfigPhase sut) - { - var config = new RadarrConfiguration - { - CustomFormats = new List - { - new() - { - QualityProfiles = new List - { - new() - { - Name = "test_profile", - ResetUnmatchedScores = true - } - } - } - } - }; - - sut.Execute(config); - - config.QualityProfiles.Should().BeEquivalentTo(new QualityProfileConfig[] - { - new() {Name = "test_profile", ResetUnmatchedScores = true} - }); - } - - [Test, AutoMockData] - public void Reset_unmatched_scores_promoted_to_quality_profiles_property_when_quality_profile_in_config( - QualityProfileConfigPhase sut) - { - var config = new RadarrConfiguration - { - QualityProfiles = new[] - { - new QualityProfileConfig - { - Name = "test_profile", - ResetUnmatchedScores = null - } - }, - CustomFormats = new List - { - new() - { - QualityProfiles = new List - { - new() - { - Name = "test_profile", - ResetUnmatchedScores = true - } - } - } - } - }; - - sut.Execute(config); - - config.QualityProfiles.Should().BeEquivalentTo(new QualityProfileConfig[] - { - new() {Name = "test_profile", ResetUnmatchedScores = true} - }); - } - - [Test, AutoMockData] - public void Reset_unmatched_scores_not_promoted_to_quality_profiles_property_when_false( - QualityProfileConfigPhase sut) - { - var config = new RadarrConfiguration - { - CustomFormats = new List - { - new() - { - QualityProfiles = new List - { - new() - { - Name = "test_profile", - ResetUnmatchedScores = false - } - } - } - } - }; - - sut.Execute(config); - - config.QualityProfiles.Should().BeEmpty(); - } - private static RadarrConfiguration SetupCfs(params CustomFormatConfig[] cfConfigs) { return new RadarrConfiguration @@ -262,49 +167,4 @@ public class QualityProfileConfigPhaseTest NewQp.Processed("test_profile2", (1, 200)) }); } - - [Test, AutoMockData] - public void Use_existing_config_quality_profile_when_specified( - [Frozen] ProcessedCustomFormatCache cache, - QualityProfileConfigPhase sut) - { - cache.AddCustomFormats(new[] - { - NewCf.DataWithScore("", "id1", 100, 1) - }); - - var config = new RadarrConfiguration - { - QualityProfiles = new[] - { - new QualityProfileConfig - { - Name = "test_profile", - ResetUnmatchedScores = true - } - }, - CustomFormats = new List - { - new() - { - TrashIds = new[] {"id1"}, - QualityProfiles = new List - { - new() - { - Name = "test_profile", - ResetUnmatchedScores = false // Should be ignored because top-level QP has it set already - } - } - } - } - }; - - sut.Execute(config); - - config.QualityProfiles.Should().BeEquivalentTo(new QualityProfileConfig[] - { - new() {Name = "test_profile", ResetUnmatchedScores = true} - }); - } } diff --git a/src/Recyclarr.Cli/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhase.cs b/src/Recyclarr.Cli/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhase.cs index 2ed261fb..411047e1 100644 --- a/src/Recyclarr.Cli/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhase.cs +++ b/src/Recyclarr.Cli/Pipelines/QualityProfile/PipelinePhases/QualityProfileConfigPhase.cs @@ -23,8 +23,6 @@ public class QualityProfileConfigPhase public IReadOnlyCollection Execute(IServiceConfiguration config) { - ProcessLegacyResetUnmatchedScores(config); - // 1. For each group of CFs that has a quality profile specified // 2. For each quality profile score config in that CF group // 3. For each CF in the group above, match it to a Guide CF object and pair it with the quality profile config @@ -61,52 +59,6 @@ public class QualityProfileConfigPhase .ToList(); } - private void ProcessLegacyResetUnmatchedScores(IServiceConfiguration config) - { - // todo: Remove this method later; it is for backward compatibility - var legacyResetUnmatchedScores = config.CustomFormats - .SelectMany(x => x.QualityProfiles) - .Where(x => x.ResetUnmatchedScores is not null) - .ToList(); - - if (legacyResetUnmatchedScores.Count > 0) - { - _log.Warning( - "DEPRECATION: Support for using `reset_unmatched_scores` under `custom_formats.quality_profiles` " + - "will be removed in a future release. Move it to the top level `quality_profiles` instead"); - } - - // Propagate the quality_profile version of ResetUnmatchedScores to the top-level quality_profile config. - var profilesThatNeedResetUnmatchedScores = legacyResetUnmatchedScores - .Where(x => x.ResetUnmatchedScores is true) - .Select(x => x.Name) - .Distinct(StringComparer.InvariantCultureIgnoreCase); - - var newQualityProfiles = config.QualityProfiles.ToList(); - - foreach (var profileName in profilesThatNeedResetUnmatchedScores) - { - var match = config.QualityProfiles.FirstOrDefault(x => x.Name.EqualsIgnoreCase(profileName)); - if (match is null) - { - _log.Debug( - "Root-level quality profile created to promote reset_unmatched_scores from CF score config: {Name}", - profileName); - newQualityProfiles.Add(new QualityProfileConfig {Name = profileName, ResetUnmatchedScores = true}); - } - else if (match.ResetUnmatchedScores is null) - { - _log.Debug( - "Score-based reset_unmatched_scores propagated to existing root-level " + - "quality profile config: {Name}", profileName); - match.ResetUnmatchedScores = true; - } - } - - // Down-cast to avoid having to make the property mutable in the interface - ((ServiceConfiguration) config).QualityProfiles = newQualityProfiles; - } - private void AddCustomFormatScoreData( IDictionary existingScoreData, QualityProfileScoreConfig profile, diff --git a/src/Recyclarr.TrashLib/Config/Parsing/ConfigDeprecations.cs b/src/Recyclarr.TrashLib/Config/Parsing/ConfigDeprecations.cs index 75d29911..727e0911 100644 --- a/src/Recyclarr.TrashLib/Config/Parsing/ConfigDeprecations.cs +++ b/src/Recyclarr.TrashLib/Config/Parsing/ConfigDeprecations.cs @@ -13,6 +13,9 @@ public static class ConfigDeprecations "See: https://recyclarr.dev/wiki/upgrade-guide/v5.0/#instances-must-now-be-named"; } + // "DEPRECATION: Support for using `reset_unmatched_scores` under `custom_formats.quality_profiles` " + + // "will be removed in a future release. Move it to the top level `quality_profiles` instead" + return null; } } diff --git a/src/Recyclarr.TrashLib/Config/Services/ServiceConfiguration.cs b/src/Recyclarr.TrashLib/Config/Services/ServiceConfiguration.cs index b55d9f93..d40d2b6e 100644 --- a/src/Recyclarr.TrashLib/Config/Services/ServiceConfiguration.cs +++ b/src/Recyclarr.TrashLib/Config/Services/ServiceConfiguration.cs @@ -18,8 +18,7 @@ public abstract record ServiceConfiguration : IServiceConfiguration public QualityDefinitionConfig? QualityDefinition { get; init; } - // todo: Remove the setter later once ResetUnmatchedScores is removed from custom format quality profiles property - public IReadOnlyCollection QualityProfiles { get; set; } = + public IReadOnlyCollection QualityProfiles { get; init; } = Array.Empty(); } @@ -37,7 +36,6 @@ public record QualityProfileScoreConfig { public string Name { get; init; } = ""; public int? Score { get; init; } - public bool? ResetUnmatchedScores { get; init; } } [UsedImplicitly(ImplicitUseTargetFlags.WithMembers)] @@ -49,7 +47,6 @@ public record QualityDefinitionConfig public record QualityProfileConfig { - // todo: Remove the setter later once reset_unmatched_scores is not in the cf.quality_profiles property anymore - public bool? ResetUnmatchedScores { get; set; } + public bool? ResetUnmatchedScores { get; init; } public string Name { get; init; } = ""; }