Remove the unreachable null service provider path from code migrations
This commit is contained in:
@@ -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 JellyfinMigrationService
|
||||
private 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;
|
||||
|
||||
@@ -20,19 +20,13 @@ internal class CodeMigration(Type migrationType, JellyfinMigrationAttribute meta
|
||||
return 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
|
||||
|
||||
Reference in New Issue
Block a user