From 7aa1c4644771bfc49b00f817c237a1deddcef855 Mon Sep 17 00:00:00 2001 From: evan314159 <110177090+evan314159@users.noreply.github.com> Date: Fri, 22 Aug 2025 16:06:39 +0800 Subject: [PATCH] Merge pull request #14653 from evan314159/coremigration Delay initialization of singleton services during migration CoreInitialisation stage --- Jellyfin.Server/Migrations/Stages/CodeMigration.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Jellyfin.Server/Migrations/Stages/CodeMigration.cs b/Jellyfin.Server/Migrations/Stages/CodeMigration.cs index 264710bce0..971b47608f 100644 --- a/Jellyfin.Server/Migrations/Stages/CodeMigration.cs +++ b/Jellyfin.Server/Migrations/Stages/CodeMigration.cs @@ -34,12 +34,8 @@ internal class CodeMigration(Type migrationType, JellyfinMigrationAttribute meta { if (service.Lifetime == ServiceLifetime.Singleton && !service.ServiceType.IsGenericTypeDefinition) { - object? serviceInstance = serviceProvider.GetService(service.ServiceType); - if (serviceInstance != null) - { - childServiceCollection.AddSingleton(service.ServiceType, serviceInstance); - continue; - } + childServiceCollection.AddSingleton(service.ServiceType, _ => serviceProvider.GetService(service.ServiceType)!); + continue; } childServiceCollection.Add(service);