mirror of https://github.com/jellyfin/jellyfin.git
Merge pull request #9987 from Sky-High/fix-migration
This commit is contained in:
commit
9de667f8ce
|
@ -93,7 +93,7 @@ namespace Jellyfin.Server.Migrations
|
||||||
|
|
||||||
private static void HandleStartupWizardCondition(IEnumerable<IMigrationRoutine> migrations, MigrationOptions migrationOptions, bool isStartWizardCompleted, ILogger logger)
|
private static void HandleStartupWizardCondition(IEnumerable<IMigrationRoutine> migrations, MigrationOptions migrationOptions, bool isStartWizardCompleted, ILogger logger)
|
||||||
{
|
{
|
||||||
if (isStartWizardCompleted || migrationOptions.Applied.Count != 0)
|
if (isStartWizardCompleted)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,8 @@ namespace Jellyfin.Server.Migrations
|
||||||
|
|
||||||
private static void PerformMigrations(IMigrationRoutine[] migrations, MigrationOptions migrationOptions, Action<MigrationOptions> saveConfiguration, ILogger logger)
|
private static void PerformMigrations(IMigrationRoutine[] migrations, MigrationOptions migrationOptions, Action<MigrationOptions> saveConfiguration, ILogger logger)
|
||||||
{
|
{
|
||||||
|
// save already applied migrations, and skip them thereafter
|
||||||
|
saveConfiguration(migrationOptions);
|
||||||
var appliedMigrationIds = migrationOptions.Applied.Select(m => m.Id).ToHashSet();
|
var appliedMigrationIds = migrationOptions.Applied.Select(m => m.Id).ToHashSet();
|
||||||
|
|
||||||
for (var i = 0; i < migrations.Length; i++)
|
for (var i = 0; i < migrations.Length; i++)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
@ -39,8 +39,23 @@ public class MigrateNetworkConfiguration : IMigrationRoutine
|
||||||
{
|
{
|
||||||
string path = Path.Combine(_applicationPaths.ConfigurationDirectoryPath, "network.xml");
|
string path = Path.Combine(_applicationPaths.ConfigurationDirectoryPath, "network.xml");
|
||||||
var oldNetworkConfigSerializer = new XmlSerializer(typeof(OldNetworkConfiguration), new XmlRootAttribute("NetworkConfiguration"));
|
var oldNetworkConfigSerializer = new XmlSerializer(typeof(OldNetworkConfiguration), new XmlRootAttribute("NetworkConfiguration"));
|
||||||
using var xmlReader = XmlReader.Create(path);
|
OldNetworkConfiguration? oldNetworkConfiguration = null;
|
||||||
var oldNetworkConfiguration = (OldNetworkConfiguration?)oldNetworkConfigSerializer.Deserialize(xmlReader);
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var xmlReader = XmlReader.Create(path))
|
||||||
|
{
|
||||||
|
oldNetworkConfiguration = (OldNetworkConfiguration?)oldNetworkConfigSerializer.Deserialize(xmlReader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Migrate NetworkConfiguration deserialize Invalid Operation error");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Migrate NetworkConfiguration deserialize error");
|
||||||
|
}
|
||||||
|
|
||||||
if (oldNetworkConfiguration is not null)
|
if (oldNetworkConfiguration is not null)
|
||||||
{
|
{
|
||||||
|
@ -82,8 +97,10 @@ public class MigrateNetworkConfiguration : IMigrationRoutine
|
||||||
|
|
||||||
var networkConfigSerializer = new XmlSerializer(typeof(NetworkConfiguration));
|
var networkConfigSerializer = new XmlSerializer(typeof(NetworkConfiguration));
|
||||||
var xmlWriterSettings = new XmlWriterSettings { Indent = true };
|
var xmlWriterSettings = new XmlWriterSettings { Indent = true };
|
||||||
using var xmlWriter = XmlWriter.Create(path, xmlWriterSettings);
|
using (var xmlWriter = XmlWriter.Create(path, xmlWriterSettings))
|
||||||
networkConfigSerializer.Serialize(xmlWriter, networkConfiguration);
|
{
|
||||||
|
networkConfigSerializer.Serialize(xmlWriter, networkConfiguration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue