diff options
| author | Cody Robibero <cody@robibe.ro> | 2022-02-04 12:36:17 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-04 20:36:17 +0100 |
| commit | c16d71562e528e1ab03a717a624f2f4ccb355e16 (patch) | |
| tree | 67b1f9cf9e3e587dd163626dbc07429d19f6b5fb | |
| parent | a2127a48ef95ab072a939ae3b459a81baaa29bd2 (diff) | |
Prevent additional errors on startup/shutdown (#6788)
| -rw-r--r-- | Jellyfin.Server/Program.cs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index f40526e22..05c59ebfb 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -224,12 +224,16 @@ namespace Jellyfin.Server } finally { - _logger.LogInformation("Running query planner optimizations in the database... This might take a while"); - // Run before disposing the application - using var context = appHost.Resolve<JellyfinDbProvider>().CreateContext(); - if (context.Database.IsSqlite()) + // Don't throw additional exception if startup failed. + if (appHost.ServiceProvider != null) { - context.Database.ExecuteSqlRaw("PRAGMA optimize"); + _logger.LogInformation("Running query planner optimizations in the database... This might take a while"); + // Run before disposing the application + using var context = appHost.Resolve<JellyfinDbProvider>().CreateContext(); + if (context.Database.IsSqlite()) + { + context.Database.ExecuteSqlRaw("PRAGMA optimize"); + } } appHost.Dispose(); |
