< Summary - Jellyfin

Information
Class: Jellyfin.Server.Migrations.PreStartupRoutines.RenameEnableGroupingIntoCollections
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/Migrations/PreStartupRoutines/RenameEnableGroupingIntoCollections.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 18
Coverable lines: 18
Total lines: 57
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

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

File(s)

/srv/git/jellyfin/Jellyfin.Server/Migrations/PreStartupRoutines/RenameEnableGroupingIntoCollections.cs

#LineLine coverage
 1using System;
 2using System.IO;
 3using System.Linq;
 4using System.Text;
 5using System.Xml.Linq;
 6using Emby.Server.Implementations;
 7using Microsoft.Extensions.Logging;
 8
 9namespace Jellyfin.Server.Migrations.PreStartupRoutines;
 10
 11/// <inheritdoc />
 12#pragma warning disable CS0618 // Type or member is obsolete
 13[JellyfinMigration("2025-04-20T04:00:00", nameof(RenameEnableGroupingIntoCollections), "E73B777D-CD5C-4E71-957A-B86B3660
 14public class RenameEnableGroupingIntoCollections : IMigrationRoutine
 15#pragma warning restore CS0618 // Type or member is obsolete
 16{
 17    private readonly ServerApplicationPaths _applicationPaths;
 18    private readonly ILogger<RenameEnableGroupingIntoCollections> _logger;
 19
 20    /// <summary>
 21    /// Initializes a new instance of the <see cref="RenameEnableGroupingIntoCollections"/> class.
 22    /// </summary>
 23    /// <param name="applicationPaths">An instance of <see cref="ServerApplicationPaths"/>.</param>
 24    /// <param name="loggerFactory">An instance of the <see cref="ILoggerFactory"/> interface.</param>
 25    public RenameEnableGroupingIntoCollections(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory)
 26    {
 027        _applicationPaths = applicationPaths;
 028        _logger = loggerFactory.CreateLogger<RenameEnableGroupingIntoCollections>();
 029    }
 30
 31    /// <inheritdoc />
 32    public void Perform()
 33    {
 034        string path = Path.Combine(_applicationPaths.ConfigurationDirectoryPath, "system.xml");
 035        if (!File.Exists(path))
 36        {
 037            _logger.LogWarning("Configuration file not found: {Path}", path);
 038            return;
 39        }
 40
 41        try
 42        {
 043            XDocument xmlDocument = XDocument.Load(path);
 044            var element = xmlDocument.Descendants("EnableGroupingIntoCollections").FirstOrDefault();
 045            if (element is not null)
 46            {
 047                element.Name = "EnableGroupingMoviesIntoCollections";
 048                _logger.LogInformation("The tag <EnableGroupingIntoCollections> was successfully renamed to <EnableGroup
 049                xmlDocument.Save(path);
 50            }
 051        }
 052        catch (Exception ex)
 53        {
 054            _logger.LogError(ex, "An error occurred while updating the XML file: {Message}", ex.Message);
 055        }
 056    }
 57}