Fixed the exception that sometimes makes ombi fallover.

pull/2814/head
TidusJar 6 years ago
parent 619ea4dbc4
commit a6b733e954

@ -47,8 +47,7 @@ namespace Ombi
instance.StoragePath = storagePath ?? string.Empty; instance.StoragePath = storagePath ?? string.Empty;
// Check if we need to migrate the settings // Check if we need to migrate the settings
CheckAndMigrate(); CheckAndMigrate();
using (var ctx = new SettingsContext()) var ctx = new SettingsContext();
{
var config = ctx.ApplicationConfigurations.ToList(); var config = ctx.ApplicationConfigurations.ToList();
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url); var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
var dbBaseUrl = config.FirstOrDefault(x => x.Type == ConfigurationTypes.BaseUrl); var dbBaseUrl = config.FirstOrDefault(x => x.Type == ConfigurationTypes.BaseUrl);
@ -89,7 +88,6 @@ namespace Ombi
dbBaseUrl.Value = baseUrl; dbBaseUrl.Value = baseUrl;
ctx.SaveChanges(); ctx.SaveChanges();
} }
}
DeleteSchedulesDb(); DeleteSchedulesDb();
@ -111,9 +109,9 @@ namespace Ombi
{ {
var doneGlobal = false; var doneGlobal = false;
var doneConfig = false; var doneConfig = false;
using (var ombi = new OmbiContext()) var ombi = new OmbiContext();
using (var settings = new SettingsContext()) var settings = new SettingsContext();
{
try try
{ {
if (ombi.Settings.Any()) if (ombi.Settings.Any())
@ -148,15 +146,11 @@ namespace Ombi
if (doneConfig) if (doneConfig)
ombi.Database.ExecuteSqlCommand("DELETE FROM ApplicationConfiguration"); ombi.Database.ExecuteSqlCommand("DELETE FROM ApplicationConfiguration");
}
// Now migrate all the external stuff // Now migrate all the external stuff
using (var ombi = new OmbiContext()) var external = new ExternalContext();
using (var external = new ExternalContext())
{
try try
{ {
if (ombi.PlexEpisode.Any()) if (ombi.PlexEpisode.Any())
{ {
external.PlexEpisode.AddRange(ombi.PlexEpisode.ToList()); external.PlexEpisode.AddRange(ombi.PlexEpisode.ToList());
@ -229,8 +223,6 @@ namespace Ombi
} }
} }
}
private static void DeleteSchedulesDb() private static void DeleteSchedulesDb()
{ {
try try

@ -237,15 +237,12 @@ namespace Ombi
app.UseMiddleware<ApiKeyMiddlewear>(); app.UseMiddleware<ApiKeyMiddlewear>();
app.UseCors("MyPolicy"); app.UseCors("MyPolicy");
//app.ApiKeyMiddlewear(app.ApplicationServices);
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(c => app.UseSwaggerUI(c =>
{ {
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
}); });
app.UseMvc(routes => app.UseMvc(routes =>
{ {
routes.MapRoute( routes.MapRoute(
@ -256,8 +253,6 @@ namespace Ombi
name: "spa-fallback", name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" }); defaults: new { controller = "Home", action = "Index" });
}); });
ombiService.Dispose();
} }
} }

Loading…
Cancel
Save