Fixed the outstanding issue on #1995

pull/1955/head^2
Jamie 6 years ago
parent b015b101ed
commit a7bc93889b

@ -135,14 +135,13 @@ namespace Ombi.Schedule.Jobs.Plex
if (existingKey != null)
{
// The rating key is all good!
existingContent = existingKey;
}
else
{
// This means the rating key has changed somehow.
// We need to reset the correct keys
// Should probably delete this and get the new one
var oldKey = existingContent.Key;
existingContent.Key = show.ratingKey;
Repo.DeleteWithoutSave(existingContent);
// Because we have changed the rating key, we need to change all children too
var episodeToChange = Repo.GetAllEpisodes().Where(x => x.GrandparentKey == oldKey);
@ -150,10 +149,11 @@ namespace Ombi.Schedule.Jobs.Plex
{
foreach (var e in episodeToChange)
{
e.GrandparentKey = existingContent.Key;
Repo.DeleteWithoutSave(e);
}
}
await Repo.SaveChangesAsync();
existingContent = null;
}
}

@ -19,5 +19,8 @@ namespace Ombi.Store.Repository
Task AddRange(IEnumerable<PlexEpisode> content);
IEnumerable<PlexServerContent> GetWhereContentByCustom(Expression<Func<PlexServerContent, bool>> predicate);
Task<PlexServerContent> GetFirstContentByCustom(Expression<Func<PlexServerContent, bool>> predicate);
Task DeleteEpisode(PlexEpisode content);
void DeleteWithoutSave(PlexServerContent content);
void DeleteWithoutSave(PlexEpisode content);
}
}

@ -103,12 +103,29 @@ namespace Ombi.Store.Repository
return Db.PlexEpisode.Include(x => x.Series).AsQueryable();
}
public void DeleteWithoutSave(PlexServerContent content)
{
Db.PlexServerContent.Remove(content);
}
public void DeleteWithoutSave(PlexEpisode content)
{
Db.PlexEpisode.Remove(content);
}
public async Task<PlexEpisode> Add(PlexEpisode content)
{
await Db.PlexEpisode.AddAsync(content);
await Db.SaveChangesAsync();
return content;
}
public async Task DeleteEpisode(PlexEpisode content)
{
Db.PlexEpisode.Remove(content);
await Db.SaveChangesAsync();
}
public async Task<PlexEpisode> GetEpisodeByKey(int key)
{
return await Db.PlexEpisode.FirstOrDefaultAsync(x => x.Key == key);

@ -57,7 +57,6 @@ namespace Ombi
config = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.RollingFile(Path.Combine(env.ContentRootPath, "Logs", "log-{Date}.txt"))
.WriteTo.SQLite("Ombi.db", "Logs", LogEventLevel.Debug)
.CreateLogger();
}
else
@ -65,7 +64,6 @@ namespace Ombi
config = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.RollingFile(Path.Combine(StoragePath.StoragePath, "Logs", "log-{Date}.txt"))
.WriteTo.SQLite(Path.Combine(StoragePath.StoragePath, "Ombi.db"), "Logs", LogEventLevel.Debug)
.CreateLogger();
}
Log.Logger = config;

@ -2,9 +2,9 @@
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
"Default": "Trace",
"System": "Trace",
"Microsoft": "Warning"
}
}
}

@ -4,7 +4,8 @@
"LogLevel": {
"Default": "Debug",
"System": "Debug",
"Microsoft": "None"
"Microsoft": "None",
"Hangfire": "None"
}
},
"ApplicationSettings": {

Loading…
Cancel
Save