|
|
|
@ -496,31 +496,31 @@ namespace Ombi.Schedule.Jobs.Plex
|
|
|
|
|
await Repo.Update(existingContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Just check the key
|
|
|
|
|
if (existingKey != null)
|
|
|
|
|
{
|
|
|
|
|
// The rating key is all good!
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// This means the rating key has changed somehow.
|
|
|
|
|
// Should probably delete this and get the new one
|
|
|
|
|
var oldKey = existingContent.Key;
|
|
|
|
|
Repo.DeleteWithoutSave(existingContent);
|
|
|
|
|
|
|
|
|
|
// Because we have changed the rating key, we need to change all children too
|
|
|
|
|
var episodeToChange = Repo.GetAllEpisodes().Cast<PlexEpisode>().Where(x => x.GrandparentKey == oldKey);
|
|
|
|
|
if (episodeToChange.Any())
|
|
|
|
|
{
|
|
|
|
|
foreach (var e in episodeToChange)
|
|
|
|
|
{
|
|
|
|
|
Repo.DeleteWithoutSave(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await Repo.SaveChangesAsync();
|
|
|
|
|
existingContent = null;
|
|
|
|
|
}
|
|
|
|
|
//// Just check the key
|
|
|
|
|
//if (existingKey != null)
|
|
|
|
|
//{
|
|
|
|
|
// // The rating key is all good!
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// // This means the rating key has changed somehow.
|
|
|
|
|
// // Should probably delete this and get the new one
|
|
|
|
|
// var oldKey = existingContent.Key;
|
|
|
|
|
// Repo.DeleteWithoutSave(existingContent);
|
|
|
|
|
|
|
|
|
|
// // Because we have changed the rating key, we need to change all children too
|
|
|
|
|
// var episodeToChange = Repo.GetAllEpisodes().Cast<PlexEpisode>().Where(x => x.GrandparentKey == oldKey);
|
|
|
|
|
// if (episodeToChange.Any())
|
|
|
|
|
// {
|
|
|
|
|
// foreach (var e in episodeToChange)
|
|
|
|
|
// {
|
|
|
|
|
// Repo.DeleteWithoutSave(e);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// await Repo.SaveChangesAsync();
|
|
|
|
|
// existingContent = null;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Also make sure it's not already being processed...
|
|
|
|
|