mirror of
https://github.com/Radarr/Radarr
synced 2026-01-24 00:13:43 +01:00
fix: add null safety to QualityProfile First/Last methods (#100)
Co-authored-by: admin <admin@ardentleatherworks.com>
This commit is contained in:
parent
b843e777de
commit
2b0f9ad03a
1 changed files with 18 additions and 4 deletions
|
|
@ -26,7 +26,12 @@ public QualityProfile()
|
|||
|
||||
public Quality FirststAllowedQuality()
|
||||
{
|
||||
var firstAllowed = Items.First(q => q.Allowed);
|
||||
var firstAllowed = Items.FirstOrDefault(q => q.Allowed);
|
||||
|
||||
if (firstAllowed == null)
|
||||
{
|
||||
return Quality.Unknown;
|
||||
}
|
||||
|
||||
if (firstAllowed.Quality != null)
|
||||
{
|
||||
|
|
@ -35,12 +40,19 @@ public Quality FirststAllowedQuality()
|
|||
|
||||
// Returning any item from the group will work,
|
||||
// returning the first because it's the true first quality.
|
||||
return firstAllowed.Items.First().Quality;
|
||||
var firstItem = firstAllowed.Items.FirstOrDefault();
|
||||
|
||||
return firstItem?.Quality ?? Quality.Unknown;
|
||||
}
|
||||
|
||||
public Quality LastAllowedQuality()
|
||||
{
|
||||
var lastAllowed = Items.Last(q => q.Allowed);
|
||||
var lastAllowed = Items.LastOrDefault(q => q.Allowed);
|
||||
|
||||
if (lastAllowed == null)
|
||||
{
|
||||
return Quality.Unknown;
|
||||
}
|
||||
|
||||
if (lastAllowed.Quality != null)
|
||||
{
|
||||
|
|
@ -49,7 +61,9 @@ public Quality LastAllowedQuality()
|
|||
|
||||
// Returning any item from the group will work,
|
||||
// returning the last because it's the true last quality.
|
||||
return lastAllowed.Items.Last().Quality;
|
||||
var lastItem = lastAllowed.Items.LastOrDefault();
|
||||
|
||||
return lastItem?.Quality ?? Quality.Unknown;
|
||||
}
|
||||
|
||||
public QualityIndex GetIndex(Quality quality, bool respectGroupOrder = false)
|
||||
|
|
|
|||
Loading…
Reference in a new issue