jellyfin/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2016-06-04 05:51:33 +00:00
using System.Linq;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Library;
namespace MediaBrowser.Server.Startup.Common.Migrations
{
public class FolderViewSettingMigration : IVersionMigration
{
private readonly IServerConfigurationManager _config;
private readonly IUserManager _userManager;
public FolderViewSettingMigration(IServerConfigurationManager config, IUserManager userManager)
{
_config = config;
_userManager = userManager;
}
public void Run()
{
var migrationKey = this.GetType().Name;
var migrationKeyList = _config.Configuration.Migrations.ToList();
if (!migrationKeyList.Contains(migrationKey))
{
if (_config.Configuration.IsStartupWizardCompleted)
{
2016-06-04 17:14:03 +00:00
if (_userManager.Users.Any(i => i.Configuration.DisplayFoldersView))
{
_config.Configuration.EnableFolderView = true;
}
2016-06-04 05:51:33 +00:00
}
migrationKeyList.Add(migrationKey);
_config.Configuration.Migrations = migrationKeyList.ToArray();
_config.SaveConfiguration();
}
}
}
}