The Free Software Media System - Server Backend & API
Remove the unreachable null service provider path from code migrations
Shadowghost63553803b194
diff --git a/Jellyfin.Server/Migrations/JellyfinMigrationService.cs b/Jellyfin.Server/Migrations/JellyfinMigrationService.csindex beafc3916f..1299896cb9 100644--- a/Jellyfin.Server/Migrations/JellyfinMigrationService.cs+++ b/Jellyfin.Server/Migrations/JellyfinMigrationService.cs@@ -183,7 +183,7 @@ internal class JellyfinMigrationService}}- public async Task MigrateStepAsync(JellyfinMigrationStageTypes stage, IServiceProvider? serviceProvider)+ public async Task MigrateStepAsync(JellyfinMigrationStageTypes stage, IServiceProvider serviceProvider){var logger = _startupLogger.With(_loggerFactory.CreateLogger<JellyfinMigrationService>()).BeginGroup($"Migrate stage {stage}.");ICollection<CodeMigration> migrationStage = (Migrations.FirstOrDefault(e => e.Stage == stage) as ICollection<CodeMigration>) ?? [];@@ -445,10 +445,10 @@ internal class JellyfinMigrationServiceprivate class InternalCodeMigration : IInternalMigration{private readonly CodeMigration _codeMigration;- private readonly IServiceProvider? _serviceProvider;+ private readonly IServiceProvider _serviceProvider;private JellyfinDbContext _dbContext;- public InternalCodeMigration(CodeMigration codeMigration, IServiceProvider? serviceProvider, JellyfinDbContext dbContext)+ public InternalCodeMigration(CodeMigration codeMigration, IServiceProvider serviceProvider, JellyfinDbContext dbContext){_codeMigration = codeMigration;_serviceProvider = serviceProvider;diff --git a/Jellyfin.Server/Migrations/Stages/CodeMigration.cs b/Jellyfin.Server/Migrations/Stages/CodeMigration.csindex 30e9f1d3d0..71706811b8 100644--- a/Jellyfin.Server/Migrations/Stages/CodeMigration.cs+++ b/Jellyfin.Server/Migrations/Stages/CodeMigration.cs@@ -20,19 +20,13 @@ internal class CodeMigration(Type migrationType, JellyfinMigrationAttribute metareturn Metadata.Order.ToString("yyyyMMddHHmmsss", CultureInfo.InvariantCulture) + "_" + Metadata.Name!;}- public async Task Perform(IServiceProvider? serviceProvider, IStartupLogger logger, CancellationToken cancellationToken)+ public async Task Perform(IServiceProvider serviceProvider, IStartupLogger logger, CancellationToken cancellationToken){if (!IsMigrationRoutine(MigrationType)){throw new InvalidOperationException($"The type {MigrationType} does not implement either IMigrationRoutine or IAsyncMigrationRoutine and is not a valid migration type");}- if (serviceProvider is null)- {- await RunAsync(Activator.CreateInstance(MigrationType)!, cancellationToken).ConfigureAwait(false);- return;- }-// The routine runs against a scope of the applications own container. Copying the application service// descriptors into a child container instead would make that child container the owner of every singleton it// forwards, so disposing it after the migration would also dispose the applications own instance of services