Fixed: Only show best pending item in Queue

This commit is contained in:
Mark McDowall 2015-03-12 16:41:07 -07:00
parent dc2c1f7928
commit 74ad841be4
1 changed files with 23 additions and 1 deletions

View File

@ -134,7 +134,17 @@ namespace NzbDrone.Core.Download.Pending
}
}
return queued;
//Return best quality release for each episode
var deduped = queued.GroupBy(q => q.Episode.Id).Select(g =>
{
var series = g.First().Series;
return g.OrderByDescending(e => e.Quality, new QualityModelComparer(series.Profile))
.ThenBy(q => PrioritizeDownloadProtocol(q.Series, q.Protocol))
.First();
});
return deduped.ToList();
}
public Queue.Queue FindPendingQueueItem(int queueId)
@ -288,6 +298,18 @@ namespace NzbDrone.Core.Download.Pending
return HashConverter.GetHashInt31(String.Format("pending-{0}-ep{1}", pendingRelease.Id, episode.Id));
}
private int PrioritizeDownloadProtocol(Series series, DownloadProtocol downloadProtocol)
{
var delayProfile = _delayProfileService.BestForTags(series.Tags);
if (downloadProtocol == delayProfile.PreferredProtocol)
{
return 0;
}
return 1;
}
public void Handle(SeriesDeletedEvent message)
{
_repository.DeleteBySeriesId(message.Series.Id);