< Summary - Jellyfin

Information
Class: Jellyfin.Server.Migrations.Routines.FixAudioData
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/Migrations/Routines/FixAudioData.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 30
Coverable lines: 30
Total lines: 76
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 1/23/2026 - 12:11:06 AM Line coverage: 0% (0/29) Branch coverage: 0% (0/6) Total lines: 775/4/2026 - 12:15:16 AM Line coverage: 0% (0/30) Branch coverage: 0% (0/6) Total lines: 76 1/23/2026 - 12:11:06 AM Line coverage: 0% (0/29) Branch coverage: 0% (0/6) Total lines: 775/4/2026 - 12:15:16 AM Line coverage: 0% (0/30) Branch coverage: 0% (0/6) Total lines: 76

Coverage delta

Coverage delta 1 -1

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Perform()0%4260%

File(s)

/srv/git/jellyfin/Jellyfin.Server/Migrations/Routines/FixAudioData.cs

#LineLine coverage
 1using System.Linq;
 2using System.Threading;
 3using Jellyfin.Data.Enums;
 4using MediaBrowser.Controller.Entities;
 5using MediaBrowser.Controller.Entities.Audio;
 6using MediaBrowser.Controller.Persistence;
 7using MediaBrowser.Model.Entities;
 8using Microsoft.Extensions.Logging;
 9
 10namespace Jellyfin.Server.Migrations.Routines
 11{
 12    /// <summary>
 13    /// Fixes the data column of audio types to be deserializable.
 14    /// </summary>
 15#pragma warning disable CS0618 // Type or member is obsolete
 16    [JellyfinMigration("2025-04-20T18:00:00", nameof(FixAudioData), "CF6FABC2-9FBE-4933-84A5-FFE52EF22A58")]
 17    [JellyfinMigrationBackup(LegacyLibraryDb = true)]
 18    internal class FixAudioData : IMigrationRoutine
 19#pragma warning restore CS0618 // Type or member is obsolete
 20    {
 21        private readonly ILogger<FixAudioData> _logger;
 22        private readonly IItemRepository _itemRepository;
 23        private readonly IItemCountService _countService;
 24        private readonly IItemPersistenceService _persistenceService;
 25
 26        public FixAudioData(
 27            ILoggerFactory loggerFactory,
 28            IItemRepository itemRepository,
 29            IItemCountService countService,
 30            IItemPersistenceService persistenceService)
 31        {
 032            _itemRepository = itemRepository;
 033            _countService = countService;
 034            _persistenceService = persistenceService;
 035            _logger = loggerFactory.CreateLogger<FixAudioData>();
 036        }
 37
 38        /// <inheritdoc/>
 39        public void Perform()
 40        {
 041            _logger.LogInformation("Backfilling audio lyrics data to database.");
 042            var startIndex = 0;
 043            var records = _countService.GetCount(new InternalItemsQuery
 044            {
 045                IncludeItemTypes = [BaseItemKind.Audio],
 046            });
 47
 048            while (startIndex < records)
 49            {
 050                var results = _itemRepository.GetItemList(new InternalItemsQuery
 051                {
 052                    IncludeItemTypes = [BaseItemKind.Audio],
 053                    StartIndex = startIndex,
 054                    Limit = 5000,
 055                    SkipDeserialization = true
 056                })
 057                .Cast<Audio>()
 058                .ToList();
 59
 060                foreach (var audio in results)
 61                {
 062                    var lyricMediaStreams = audio.GetMediaStreams().Where(s => s.Type == MediaStreamType.Lyric).Select(s
 063                    if (lyricMediaStreams.Count > 0)
 64                    {
 065                        audio.HasLyrics = true;
 066                        audio.LyricFiles = lyricMediaStreams;
 67                    }
 68                }
 69
 070                _persistenceService.SaveItems(results, CancellationToken.None);
 071                startIndex += results.Count;
 072                _logger.LogInformation("Backfilled data for {UpdatedRecords} of {TotalRecords} audio records", startInde
 73            }
 074        }
 75    }
 76}