add error handling with migrations
This commit is contained in:
parent
58d4534a26
commit
7b094f3f8a
|
@ -359,12 +359,18 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
{
|
||||
var migrations = new List<IVersionMigration>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,6 @@
|
|||
<Compile Include="Migrations\DbMigration.cs" />
|
||||
<Compile Include="Migrations\MovieDbEpisodeProviderMigration.cs" />
|
||||
<Compile Include="Migrations\OmdbEpisodeProviderMigration.cs" />
|
||||
<Compile Include="Migrations\RenameXmlOptions.cs" />
|
||||
<Compile Include="NativeEnvironment.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StartupOptions.cs" />
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user