< Summary - Jellyfin

Information
Class: Jellyfin.Server.Migrations.Stages.CodeMigration
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/Migrations/Stages/CodeMigration.cs
Line coverage
88%
Covered lines: 8
Uncovered lines: 1
Coverable lines: 9
Total lines: 44
Line coverage: 88.8%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/31/2026 - 12:15:44 AM Line coverage: 62.9% (17/27) Branch coverage: 57.1% (8/14) Total lines: 8710/29/2026 - 12:17:11 AM Line coverage: 93.3% (14/15) Branch coverage: 50% (3/6) Total lines: 6411/13/2026 - 12:19:51 AM Line coverage: 88.8% (8/9) Branch coverage: 50% (1/2) Total lines: 44 5/31/2026 - 12:15:44 AM Line coverage: 62.9% (17/27) Branch coverage: 57.1% (8/14) Total lines: 8710/29/2026 - 12:17:11 AM Line coverage: 93.3% (14/15) Branch coverage: 50% (3/6) Total lines: 6411/13/2026 - 12:19:51 AM Line coverage: 88.8% (8/9) Branch coverage: 50% (1/2) Total lines: 44

Coverage delta

Coverage delta 31 -31

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
BuildCodeMigrationId()100%11100%
Perform()50%2287.5%

File(s)

/srv/git/jellyfin/Jellyfin.Server/Migrations/Stages/CodeMigration.cs

#LineLine coverage
 1using System;
 2using System.Globalization;
 3using System.Threading;
 4using System.Threading.Tasks;
 5using Jellyfin.Server.ServerSetupApp;
 6using Microsoft.Extensions.DependencyInjection;
 7
 8namespace Jellyfin.Server.Migrations.Stages;
 9
 10internal class CodeMigration(Type migrationType, JellyfinMigrationAttribute metadata, JellyfinMigrationBackupAttribute? 
 11{
 12    public Type MigrationType { get; } = migrationType;
 13
 14    public JellyfinMigrationAttribute Metadata { get; } = metadata;
 15
 16    public JellyfinMigrationBackupAttribute? BackupRequirements { get; set; } = migrationBackupAttribute;
 17
 18    public string BuildCodeMigrationId()
 19    {
 63072720        return Metadata.Order.ToString("yyyyMMddHHmmsss", CultureInfo.InvariantCulture) + "_" + Metadata.Name!;
 21    }
 22
 23    public async Task Perform(IServiceProvider serviceProvider, IStartupLogger logger, CancellationToken cancellationTok
 24    {
 13725        if (!typeof(IAsyncMigrationRoutine).IsAssignableFrom(MigrationType))
 26        {
 027            throw new InvalidOperationException($"The type {MigrationType} does not implement IAsyncMigrationRoutine and
 28        }
 29
 30        // The routine runs against a scope of the applications own container. Copying the application service
 31        // descriptors into a child container instead would make that child container the owner of every singleton it
 32        // forwards, so disposing it after the migration would also dispose the applications own instance of services
 33        // like the ProviderManager and leave the server broken until the next restart.
 13734        var scope = serviceProvider.CreateAsyncScope();
 13735        await using (scope.ConfigureAwait(false))
 36        {
 37            // Nests everything the routine logs through an injected IStartupLogger under the migrations own topic.
 13738            using (StartupLogger.BeginAmbientTopic(logger.Topic))
 39            {
 13740                await ((IAsyncMigrationRoutine)ActivatorUtilities.CreateInstance(scope.ServiceProvider, MigrationType)).
 13741            }
 42        }
 13743    }
 44}

Methods/Properties

BuildCodeMigrationId()
Perform()