Move MigrateRatingLevels migration to preStartup

This commit is contained in:
Shadowghost 2023-02-20 11:49:40 +01:00
parent 5cdb0c7932
commit f0251f86cb
2 changed files with 10 additions and 9 deletions

View File

@ -22,7 +22,8 @@ namespace Jellyfin.Server.Migrations
private static readonly Type[] _preStartupMigrationTypes = private static readonly Type[] _preStartupMigrationTypes =
{ {
typeof(PreStartupRoutines.CreateNetworkConfiguration), typeof(PreStartupRoutines.CreateNetworkConfiguration),
typeof(PreStartupRoutines.MigrateMusicBrainzTimeout) typeof(PreStartupRoutines.MigrateMusicBrainzTimeout),
typeof(PreStartupRoutines.MigrateRatingLevels)
}; };
/// <summary> /// <summary>
@ -39,8 +40,7 @@ namespace Jellyfin.Server.Migrations
typeof(Routines.ReaddDefaultPluginRepository), typeof(Routines.ReaddDefaultPluginRepository),
typeof(Routines.MigrateDisplayPreferencesDb), typeof(Routines.MigrateDisplayPreferencesDb),
typeof(Routines.RemoveDownloadImagesInAdvance), typeof(Routines.RemoveDownloadImagesInAdvance),
typeof(Routines.MigrateAuthenticationDb), typeof(Routines.MigrateAuthenticationDb)
typeof(Routines.MigrateRatingLevels)
}; };
/// <summary> /// <summary>

View File

@ -2,11 +2,12 @@ using System;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using Emby.Server.Implementations;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SQLitePCL.pretty; using SQLitePCL.pretty;
namespace Jellyfin.Server.Migrations.Routines namespace Jellyfin.Server.Migrations.PreStartupRoutines
{ {
/// <summary> /// <summary>
/// Migrate rating levels to new rating level system. /// Migrate rating levels to new rating level system.
@ -15,12 +16,12 @@ namespace Jellyfin.Server.Migrations.Routines
{ {
private const string DbFilename = "library.db"; private const string DbFilename = "library.db";
private readonly ILogger<MigrateRatingLevels> _logger; private readonly ILogger<MigrateRatingLevels> _logger;
private readonly IServerApplicationPaths _paths; private readonly IServerApplicationPaths _applicationPaths;
public MigrateRatingLevels(ILogger<MigrateRatingLevels> logger, IServerApplicationPaths paths) public MigrateRatingLevels(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory)
{ {
_logger = logger; _applicationPaths = applicationPaths;
_paths = paths; _logger = loggerFactory.CreateLogger<MigrateRatingLevels>();
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -35,7 +36,7 @@ namespace Jellyfin.Server.Migrations.Routines
/// <inheritdoc/> /// <inheritdoc/>
public void Perform() public void Perform()
{ {
var dataPath = _paths.DataPath; var dataPath = _applicationPaths.DataPath;
var dbPath = Path.Combine(dataPath, DbFilename); var dbPath = Path.Combine(dataPath, DbFilename);
using (var connection = SQLite3.Open( using (var connection = SQLite3.Open(
dbPath, dbPath,