Prevented #2848 from erroring out causing further issues.

This commit is contained in:
TidusJar 2019-02-25 08:47:16 +00:00
parent 6a36fa3974
commit d1086e8ae0

View file

@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Ombi.Core.Models.Search; using Ombi.Core.Models.Search;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using Ombi.Store.Repository.Requests; using Ombi.Store.Repository.Requests;
@ -33,9 +34,12 @@ namespace Ombi.Core.Rule.Rules.Search
} }
public static async Task SingleEpisodeCheck(bool useImdb, IQueryable<PlexEpisode> allEpisodes, EpisodeRequests episode, public static async Task SingleEpisodeCheck(bool useImdb, IQueryable<PlexEpisode> allEpisodes, EpisodeRequests episode,
SeasonRequests season, PlexServerContent item, bool useTheMovieDb, bool useTvDb) SeasonRequests season, PlexServerContent item, bool useTheMovieDb, bool useTvDb, ILogger log)
{ {
PlexEpisode epExists = null; PlexEpisode epExists = null;
try
{
if (useImdb) if (useImdb)
{ {
epExists = await allEpisodes.FirstOrDefaultAsync(x => epExists = await allEpisodes.FirstOrDefaultAsync(x =>
@ -56,6 +60,11 @@ namespace Ombi.Core.Rule.Rules.Search
x.EpisodeNumber == episode.EpisodeNumber && x.SeasonNumber == season.SeasonNumber && x.EpisodeNumber == episode.EpisodeNumber && x.SeasonNumber == season.SeasonNumber &&
x.Series.TvDbId == item.TvDbId); x.Series.TvDbId == item.TvDbId);
} }
}
catch (Exception e)
{
log.LogError(e, "Exception thrown when attempting to check if something is available");
}
if (epExists != null) if (epExists != null)
{ {