Handle null values for Items and FormatItems

Updated the conversion of Items and FormatItems to handle null values gracefully by providing default empty lists.
This commit is contained in:
Matthew van der Hoorn 2026-04-13 08:04:42 +02:00 committed by GitHub
parent 4b85fab05b
commit 0de0a2606e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -105,11 +105,11 @@ public static QualityProfile ToModel(this QualityProfileResource resource)
Name = resource.Name,
UpgradeAllowed = resource.UpgradeAllowed,
Cutoff = resource.Cutoff,
Items = resource.Items.ConvertAll(ToModel),
Items = resource.Items?.ConvertAll(ToModel) ?? new List<QualityProfile>(),
MinFormatScore = resource.MinFormatScore,
CutoffFormatScore = resource.CutoffFormatScore,
MinUpgradeFormatScore = resource.MinUpgradeFormatScore,
FormatItems = resource.FormatItems.ConvertAll(ToModel),
FormatItems = resource.FormatItems?.ConvertAll(ToModel) ?? new List<QualityProfileQualityItem>(),
Language = resource.Language
};
}
@ -126,7 +126,7 @@ public static QualityProfileQualityItem ToModel(this QualityProfileQualityItemRe
Id = resource.Id,
Name = resource.Name,
Quality = resource.Quality != null ? (NzbDrone.Core.Qualities.Quality)resource.Quality.Id : null,
Items = resource.Items.ConvertAll(ToModel),
Items = resource.Items?.ConvertAll(ToModel) ?? new List<QualityProfileQualityItem>(),
Allowed = resource.Allowed
};
}