Skip to content

Commit

Permalink
fix(plex): stop the plex sync from deleting episodes when we can't fi…
Browse files Browse the repository at this point in the history
…nd the plex key
  • Loading branch information
tidusjar committed Sep 20, 2022
1 parent 386736f commit 66b05e5
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,31 +496,31 @@ private async Task ProcessTvShow(PlexServers servers, Metadata show, HashSet<Ple
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...
Expand Down

0 comments on commit 66b05e5

Please sign in to comment.