From bf5067466dc4a039ce8e26a48710be19c81de785 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 26 Mar 2017 13:01:59 -0700 Subject: [PATCH] Guard against a null file showing an exception in release rejections Fixes #1755 --- .../DecisionEngine/Specifications/CutoffSpecification.cs | 9 +++++++-- .../Specifications/UpgradeDiskSpecification.cs | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs index 6dfdbc64c..451835ac9 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/CutoffSpecification.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -22,8 +22,13 @@ namespace NzbDrone.Core.DecisionEngine.Specifications { foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) { - _logger.Debug("Comparing file quality with report. Existing file is {0}", file.Quality); + if (file == null) + { + _logger.Debug("File is no longer avaialble, skipping this file."); + continue; + } + _logger.Debug("Comparing file quality with report. Existing file is {0}", file.Quality); if (!_qualityUpgradableSpecification.CutoffNotMet(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality)) { diff --git a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs index 5a24b6305..04b4abfe1 100644 --- a/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs +++ b/src/NzbDrone.Core/DecisionEngine/Specifications/UpgradeDiskSpecification.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using NLog; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser.Model; @@ -22,6 +22,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications { foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value)) { + if(file == null) + { + _logger.Debug("File is no longer avaialble, skipping this file."); + continue; + } + _logger.Debug("Comparing file quality with report. Existing file is {0}", file.Quality); if (!_qualityUpgradableSpecification.IsUpgradable(subject.Series.Profile, file.Quality, subject.ParsedEpisodeInfo.Quality))