瀏覽代碼

Merge pull request #14653 from evan314159/coremigration

Delay initialization of singleton services during migration CoreInitialisation stage
evan314159 3 天之前
父節點
當前提交
7aa1c46447
共有 1 個文件被更改,包括 2 次插入6 次删除
  1. 2 6
      Jellyfin.Server/Migrations/Stages/CodeMigration.cs

+ 2 - 6
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);