From 1d5f1bc474c3d685e04f409b956ccc431cd05ee5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Jan 2015 00:19:13 -0500 Subject: sync updates --- .../Library/UserManager.cs | 38 +++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations/Library/UserManager.cs') diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index edcf7255d..3d6432636 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -73,10 +73,11 @@ namespace MediaBrowser.Server.Implementations.Library private readonly Func _dtoServiceFactory; private readonly Func _connectFactory; private readonly Func _channelManager; + private readonly Func _libraryManager; private readonly IServerApplicationHost _appHost; private readonly IFileSystem _fileSystem; - public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory, Func connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func channelManager) + public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory, Func connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func channelManager, Func libraryManager) { _logger = logger; UserRepository = userRepository; @@ -89,6 +90,7 @@ namespace MediaBrowser.Server.Implementations.Library _jsonSerializer = jsonSerializer; _fileSystem = fileSystem; _channelManager = channelManager; + _libraryManager = libraryManager; ConfigurationManager = configurationManager; Users = new List(); @@ -173,6 +175,7 @@ namespace MediaBrowser.Server.Implementations.Library { await DoPolicyMigration(user).ConfigureAwait(false); await DoChannelMigration(user).ConfigureAwait(false); + await DoLibraryMigration(user).ConfigureAwait(false); } // If there are no local users with admin rights, make them all admins @@ -389,6 +392,39 @@ namespace MediaBrowser.Server.Implementations.Library } } + private async Task DoLibraryMigration(User user) + { + if (user.Policy.BlockedMediaFolders != null) + { + if (user.Policy.BlockedMediaFolders.Length > 0) + { + user.Policy.EnableAllFolders = false; + + try + { + user.Policy.EnabledFolders = _libraryManager().RootFolder + .Children + .Where(i => !user.Policy.BlockedMediaFolders.Contains(i.Name, StringComparer.OrdinalIgnoreCase) && !user.Policy.BlockedMediaFolders.Contains(i.Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + .Select(i => i.Id.ToString("N")) + .ToArray(); + } + catch + { + user.Policy.EnabledFolders = new string[] { }; + } + } + else + { + user.Policy.EnableAllFolders = true; + user.Policy.EnabledFolders = new string[] { }; + } + + user.Policy.BlockedMediaFolders = null; + + await UpdateUserPolicy(user, user.Policy, false); + } + } + public UserDto GetUserDto(User user, string remoteEndPoint = null) { if (user == null) -- cgit v1.2.3