Fixed: Don't fail AcceptableSizeSpec when no Album Releases exist for Album

This commit is contained in:
Qstick 2021-04-17 23:44:00 -04:00
parent 9696eb5ca2
commit 1752fe5c53
1 changed files with 14 additions and 2 deletions

View File

@ -35,10 +35,18 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
var qualityDefinition = _qualityDefinitionService.Get(quality); var qualityDefinition = _qualityDefinitionService.Get(quality);
var minReleaseDuration = subject.Albums.Select(a => a.AlbumReleases.Value.Where(r => r.Monitored || a.AnyReleaseOk).Select(r => r.Duration).MinOrDefault()).Sum() / 1000;
var maxReleaseDuration = subject.Albums.Select(a => a.AlbumReleases.Value.Where(r => r.Monitored || a.AnyReleaseOk).Select(r => r.Duration).MaxOrDefault()).Sum() / 1000;
if (qualityDefinition.MinSize.HasValue) if (qualityDefinition.MinSize.HasValue)
{ {
if (maxReleaseDuration == 0)
{
_logger.Debug("Album duration is 0, unable to validate size until it is available, rejecting");
return Decision.Reject("Album duration is 0, unable to validate size until it is available");
}
var minSize = qualityDefinition.MinSize.Value.Kilobits(); var minSize = qualityDefinition.MinSize.Value.Kilobits();
var minReleaseDuration = subject.Albums.Select(a => a.AlbumReleases.Value.Where(r => r.Monitored || a.AnyReleaseOk).Select(r => r.Duration).Min()).Sum() / 1000;
//Multiply minSize by smallest release duration //Multiply minSize by smallest release duration
minSize = minSize * minReleaseDuration; minSize = minSize * minReleaseDuration;
@ -57,10 +65,14 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
{ {
_logger.Debug("Max size is unlimited, skipping size check"); _logger.Debug("Max size is unlimited, skipping size check");
} }
else if (maxReleaseDuration == 0)
{
_logger.Debug("Album duration is 0, unable to validate size until it is available, rejecting");
return Decision.Reject("Album duration is 0, unable to validate size until it is available");
}
else else
{ {
var maxSize = qualityDefinition.MaxSize.Value.Kilobits(); var maxSize = qualityDefinition.MaxSize.Value.Kilobits();
var maxReleaseDuration = subject.Albums.Select(a => a.AlbumReleases.Value.Where(r => r.Monitored || a.AnyReleaseOk).Select(r => r.Duration).Max()).Sum() / 1000;
//Multiply maxSize by Album.Duration //Multiply maxSize by Album.Duration
maxSize = maxSize * maxReleaseDuration; maxSize = maxSize * maxReleaseDuration;