2
0
Эх сурвалжийг харах

Prevent additional errors on startup/shutdown (#6788)

Cody Robibero 3 жил өмнө
parent
commit
c16d71562e

+ 9 - 5
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();