2014-11-11 03:41:55 +00:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Startup.Common.Migrations
|
|
|
|
|
{
|
2014-12-16 05:01:57 +00:00
|
|
|
|
public class RenameXmlOptions : IVersionMigration
|
2014-11-11 03:41:55 +00:00
|
|
|
|
{
|
|
|
|
|
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++)
|
|
|
|
|
{
|
2014-12-21 05:57:06 +00:00
|
|
|
|
if (string.Equals(options[i], "Media Browser Legacy Xml", StringComparison.OrdinalIgnoreCase))
|
2014-11-11 03:41:55 +00:00
|
|
|
|
{
|
2014-12-21 05:57:06 +00:00
|
|
|
|
options[i] = "Media Browser Xml";
|
2014-11-11 03:41:55 +00:00
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|