1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed: Protect Queue Specification from NRE

Fixes #3665
This commit is contained in:
Qstick 2019-08-05 20:40:05 -04:00
parent 1cde85bba8
commit a771871cf8

View File

@ -26,25 +26,38 @@ public QueueSpecification(IQueueService queueService,
public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria)
{
var queue = _queueService.GetQueue()
.Select(q => q.RemoteMovie).ToList();
var matchingSeries = queue.Where(q => q.Movie.Id == subject.Movie.Id);
var queue = _queueService.GetQueue();
var matchingMovies = queue.Where(q => q.RemoteMovie?.Movie != null &&
q.RemoteMovie.Movie.Id == subject.Movie.Id)
.ToList();
foreach (var remoteEpisode in matchingSeries)
foreach (var queueItem in matchingMovies)
{
_logger.Debug("Checking if existing release in queue meets cutoff. Queued quality is: {0}", remoteEpisode.ParsedMovieInfo.Quality);
var remoteMovie = queueItem.RemoteMovie;
var qualityProfile = subject.Movie.Profile.Value;
if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Movie.Profile, remoteEpisode.ParsedMovieInfo.Quality, subject.ParsedMovieInfo.Quality))
_logger.Debug("Checking if existing release in queue meets cutoff. Queued quality is: {0}", remoteMovie.ParsedMovieInfo.Quality);
if (!_qualityUpgradableSpecification.CutoffNotMet(qualityProfile, remoteMovie.ParsedMovieInfo.Quality, subject.ParsedMovieInfo.Quality))
{
return Decision.Reject("Quality for release in queue already meets cutoff: {0}", remoteEpisode.ParsedMovieInfo.Quality);
return Decision.Reject("Quality for release in queue already meets cutoff: {0}", remoteMovie.ParsedMovieInfo.Quality);
}
_logger.Debug("Checking if release is higher quality than queued release. Queued quality is: {0}", remoteEpisode.ParsedMovieInfo.Quality);
_logger.Debug("Checking if release is higher quality than queued release. Queued quality is: {0}", remoteMovie.ParsedMovieInfo.Quality);
if (!_qualityUpgradableSpecification.IsUpgradable(subject.Movie.Profile, remoteEpisode.ParsedMovieInfo.Quality, subject.ParsedMovieInfo.Quality))
if (!_qualityUpgradableSpecification.IsUpgradable(qualityProfile, remoteMovie.ParsedMovieInfo.Quality, subject.ParsedMovieInfo.Quality))
{
return Decision.Reject("Quality for release in queue is of equal or higher preference: {0}", remoteEpisode.ParsedMovieInfo.Quality);
return Decision.Reject("Quality for release in queue is of equal or higher preference: {0}", remoteMovie.ParsedMovieInfo.Quality);
}
_logger.Debug("Checking if profiles allow upgrading. Queued: {0}", remoteMovie.ParsedMovieInfo.Quality);
if (!_qualityUpgradableSpecification.IsUpgradeAllowed(subject.Movie.Profile,
remoteMovie.ParsedMovieInfo.Quality,
subject.ParsedMovieInfo.Quality))
{
return Decision.Reject("Another release is queued and the Quality profile does not allow upgrades");
}
}