From 7b094f3f8a89bd058852b772f2b535f4dede4f73 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 24 May 2016 13:36:23 -0400 Subject: [PATCH] add error handling with migrations --- .../ApplicationHost.cs | 19 +++++- .../MediaBrowser.Server.Startup.Common.csproj | 1 - .../Migrations/RenameXmlOptions.cs | 61 ------------------- 3 files changed, 16 insertions(+), 65 deletions(-) delete mode 100644 MediaBrowser.Server.Startup.Common/Migrations/RenameXmlOptions.cs diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index eef8c51938..7b958779da 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -359,12 +359,18 @@ namespace MediaBrowser.Server.Startup.Common { var migrations = new List { - new RenameXmlOptions(ServerConfigurationManager) }; foreach (var task in migrations) { - task.Run(); + try + { + task.Run(); + } + catch (Exception ex) + { + Logger.ErrorException("Error running migration", ex); + } } } @@ -379,7 +385,14 @@ namespace MediaBrowser.Server.Startup.Common foreach (var task in migrations) { - task.Run(); + try + { + task.Run(); + } + catch (Exception ex) + { + Logger.ErrorException("Error running migration", ex); + } } } diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj index 19ce9ed9e3..d0769f4888 100644 --- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj +++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj @@ -75,7 +75,6 @@ - diff --git a/MediaBrowser.Server.Startup.Common/Migrations/RenameXmlOptions.cs b/MediaBrowser.Server.Startup.Common/Migrations/RenameXmlOptions.cs deleted file mode 100644 index 49114b96f3..0000000000 --- a/MediaBrowser.Server.Startup.Common/Migrations/RenameXmlOptions.cs +++ /dev/null @@ -1,61 +0,0 @@ -using MediaBrowser.Controller.Configuration; -using System; - -namespace MediaBrowser.Server.Startup.Common.Migrations -{ - public class RenameXmlOptions : IVersionMigration - { - private readonly IServerConfigurationManager _config; - - public RenameXmlOptions(IServerConfigurationManager config) - { - _config = config; - } - - public void Run() - { - var changed = false; - - foreach (var option in _config.Configuration.MetadataOptions) - { - if (Migrate(option.DisabledMetadataSavers)) - { - changed = true; - } - if (Migrate(option.LocalMetadataReaderOrder)) - { - changed = true; - } - } - - if (changed) - { - _config.SaveConfiguration(); - } - } - - private bool Migrate(string[] options) - { - var changed = false; - - if (options != null) - { - for (var i = 0; i < options.Length; i++) - { - if (string.Equals(options[i], "Media Browser Legacy Xml", StringComparison.OrdinalIgnoreCase)) - { - options[i] = "Emby Xml"; - changed = true; - } - else if (string.Equals(options[i], "Media Browser Xml", StringComparison.OrdinalIgnoreCase)) - { - options[i] = "Emby Xml"; - changed = true; - } - } - } - - return changed; - } - } -}