diff options
| author | Sky-High <el.bakkum@gmail.com> | 2023-07-11 20:28:52 +0200 |
|---|---|---|
| committer | Sky-High <el.bakkum@gmail.com> | 2023-07-11 20:28:52 +0200 |
| commit | 06b80a8cededab5020ba23c36e62855252ae3b0d (patch) | |
| tree | 2709f4df5ecce3ba1ffcff08132a4bfb39e346e1 | |
| parent | 78c17ba895b16a063e30171a5f2c663d65e37c2c (diff) | |
fix for MigrateNetworkConfiguration.cs
| -rw-r--r-- | Jellyfin.Server/Migrations/PreStartupRoutines/MigrateNetworkConfiguration.cs | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/Jellyfin.Server/Migrations/PreStartupRoutines/MigrateNetworkConfiguration.cs b/Jellyfin.Server/Migrations/PreStartupRoutines/MigrateNetworkConfiguration.cs index 3b32e6043..a4379197c 100644 --- a/Jellyfin.Server/Migrations/PreStartupRoutines/MigrateNetworkConfiguration.cs +++ b/Jellyfin.Server/Migrations/PreStartupRoutines/MigrateNetworkConfiguration.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Xml; using System.Xml.Serialization; @@ -39,8 +39,23 @@ public class MigrateNetworkConfiguration : IMigrationRoutine { string path = Path.Combine(_applicationPaths.ConfigurationDirectoryPath, "network.xml"); var oldNetworkConfigSerializer = new XmlSerializer(typeof(OldNetworkConfiguration), new XmlRootAttribute("NetworkConfiguration")); - using var xmlReader = XmlReader.Create(path); - var oldNetworkConfiguration = (OldNetworkConfiguration?)oldNetworkConfigSerializer.Deserialize(xmlReader); + OldNetworkConfiguration? oldNetworkConfiguration = null; + + 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) { @@ -82,8 +97,10 @@ public class MigrateNetworkConfiguration : IMigrationRoutine var networkConfigSerializer = new XmlSerializer(typeof(NetworkConfiguration)); var xmlWriterSettings = new XmlWriterSettings { Indent = true }; - using var xmlWriter = XmlWriter.Create(path, xmlWriterSettings); - networkConfigSerializer.Serialize(xmlWriter, networkConfiguration); + using (var xmlWriter = XmlWriter.Create(path, xmlWriterSettings)) + { + networkConfigSerializer.Serialize(xmlWriter, networkConfiguration); + } } } |
