Extract "migrations" config name to a proper constant

This commit is contained in:
Vasily 2020-03-05 20:37:49 +03:00
parent ecaa7f8014
commit ccafebca68
2 changed files with 8 additions and 3 deletions

View File

@ -27,7 +27,7 @@ namespace Jellyfin.Server.Migrations
public static void Run(CoreAppHost host, ILoggerFactory loggerFactory) public static void Run(CoreAppHost host, ILoggerFactory loggerFactory)
{ {
var logger = loggerFactory.CreateLogger<MigrationRunner>(); var logger = loggerFactory.CreateLogger<MigrationRunner>();
var migrationOptions = ((IConfigurationManager)host.ServerConfigurationManager).GetConfiguration<MigrationOptions>("migrations"); var migrationOptions = ((IConfigurationManager)host.ServerConfigurationManager).GetConfiguration<MigrationOptions>(MigrationsListStore.StoreKey);
var applied = migrationOptions.Applied.ToList(); var applied = migrationOptions.Applied.ToList();
for (var i = 0; i < Migrations.Length; i++) for (var i = 0; i < Migrations.Length; i++)
@ -56,7 +56,7 @@ namespace Jellyfin.Server.Migrations
{ {
logger.LogInformation("Some migrations were run, saving the state"); logger.LogInformation("Some migrations were run, saving the state");
migrationOptions.Applied = applied.ToArray(); migrationOptions.Applied = applied.ToArray();
host.ServerConfigurationManager.SaveConfiguration("migrations", migrationOptions); host.ServerConfigurationManager.SaveConfiguration(MigrationsListStore.StoreKey, migrationOptions);
} }
} }
} }

View File

@ -7,13 +7,18 @@ namespace Jellyfin.Server.Migrations
/// </summary> /// </summary>
public class MigrationsListStore : ConfigurationStore public class MigrationsListStore : ConfigurationStore
{ {
/// <summary>
/// The name of the configuration in the storage.
/// </summary>
public static readonly string StoreKey = "migrations";
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MigrationsListStore"/> class. /// Initializes a new instance of the <see cref="MigrationsListStore"/> class.
/// </summary> /// </summary>
public MigrationsListStore() public MigrationsListStore()
{ {
ConfigurationType = typeof(MigrationOptions); ConfigurationType = typeof(MigrationOptions);
Key = "migrations"; Key = StoreKey;
} }
} }
} }