Files
pgsql-jellyfin/Jellyfin.Server/Migrations/PreStartupRoutines/RenameEnableGroupingIntoCollections.cs
wjones af1152b001 Refactor: standardize namespace and using directive style
Refactored all C# test files to use explicit namespace declarations and moved all using directives inside the namespace block for consistency. Updated assembly info and cache files to reflect the new build. Adjusted MvcTestingAppManifest.json to use fully qualified assembly names. No functional changes; all updates are related to code style, organization, and project metadata.
2026-02-20 16:26:53 -05:00

62 lines
2.5 KiB
C#

// <copyright file="RenameEnableGroupingIntoCollections.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Jellyfin.Server.Migrations.PreStartupRoutines;
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Emby.Server.Implementations;
using Microsoft.Extensions.Logging;
/// <inheritdoc />
#pragma warning disable CS0618 // Type or member is obsolete
[JellyfinMigration("2025-04-20T04:00:00", nameof(RenameEnableGroupingIntoCollections), "E73B777D-CD5C-4E71-957A-B86B3660B7CF", Stage = Stages.JellyfinMigrationStageTypes.PreInitialisation)]
public class RenameEnableGroupingIntoCollections : IMigrationRoutine
#pragma warning restore CS0618 // Type or member is obsolete
{
private readonly ServerApplicationPaths _applicationPaths;
private readonly ILogger<RenameEnableGroupingIntoCollections> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="RenameEnableGroupingIntoCollections"/> class.
/// </summary>
/// <param name="applicationPaths">An instance of <see cref="ServerApplicationPaths"/>.</param>
/// <param name="loggerFactory">An instance of the <see cref="ILoggerFactory"/> interface.</param>
public RenameEnableGroupingIntoCollections(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory)
{
_applicationPaths = applicationPaths;
_logger = loggerFactory.CreateLogger<RenameEnableGroupingIntoCollections>();
}
/// <inheritdoc />
public void Perform()
{
string path = Path.Combine(_applicationPaths.ConfigurationDirectoryPath, "system.xml");
if (!File.Exists(path))
{
_logger.LogWarning("Configuration file not found: {Path}", path);
return;
}
try
{
XDocument xmlDocument = XDocument.Load(path);
var element = xmlDocument.Descendants("EnableGroupingIntoCollections").FirstOrDefault();
if (element is not null)
{
element.Name = "EnableGroupingMoviesIntoCollections";
_logger.LogInformation("The tag <EnableGroupingIntoCollections> was successfully renamed to <EnableGroupingMoviesIntoCollections>.");
xmlDocument.Save(path);
}
}
catch (Exception ex)
{
_logger.LogError(ex, "An error occurred while updating the XML file: {Message}", ex.Message);
}
}
}