From 6adb0351ea9b3d0837c81952964b3315ffa92429 Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 21 Jun 2018 22:33:05 +0100 Subject: [PATCH] Fixed #2348 --- .../Jobs/Plex/PlexContentSync.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs index fec69bcc3..9184755f0 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs @@ -104,13 +104,13 @@ namespace Ombi.Schedule.Jobs.Plex BackgroundJob.Enqueue(() => EpisodeSync.Start()); } - if (processedContent.HasProcessedContent && recentlyAddedSearch) + if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch) { // Just check what we send it BackgroundJob.Enqueue(() => Metadata.ProcessPlexServerContent(processedContent.Content)); } - if (processedContent.HasProcessedEpisodes && recentlyAddedSearch) + if ((processedContent?.HasProcessedEpisodes ?? false) && recentlyAddedSearch) { BackgroundJob.Enqueue(() => Checker.Start()); } @@ -165,7 +165,7 @@ namespace Ombi.Schedule.Jobs.Plex { Logger.LogInformation("Found some episodes, this must be a recently added sync"); var count = 0; - foreach (var epInfo in content.Metadata) + foreach (var epInfo in content.Metadata ?? new Metadata[]{}) { count++; var grandParentKey = epInfo.grandparentRatingKey; @@ -199,9 +199,11 @@ namespace Ombi.Schedule.Jobs.Plex // Save just to make sure we don't leave anything hanging await Repo.SaveChangesAsync(); - - var episodesAdded = await EpisodeSync.ProcessEpsiodes(content.Metadata, allEps); - episodesProcessed.AddRange(episodesAdded.Select(x => x.Id)); + if (content.Metadata != null) + { + var episodesAdded = await EpisodeSync.ProcessEpsiodes(content.Metadata, allEps); + episodesProcessed.AddRange(episodesAdded.Select(x => x.Id)); + } } if (content.viewGroup.Equals(PlexMediaType.Show.ToString(), StringComparison.CurrentCultureIgnoreCase)) { @@ -350,7 +352,7 @@ namespace Ombi.Schedule.Jobs.Plex } // Do we already have this item? - // Let's try and match + // Let's try and match var existingContent = await Repo.GetFirstContentByCustom(x => x.Title == show.title && x.ReleaseYear == show.year.ToString() && x.Type == PlexMediaTypeEntity.Show); @@ -371,6 +373,10 @@ namespace Ombi.Schedule.Jobs.Plex await Repo.Delete(existingKey); existingKey = null; } + else if(existingContent == null) + { + existingContent = await Repo.GetFirstContentByCustom(x => x.Key == show.ratingKey); + } } if (existingContent != null)