|
@@ -73,10 +73,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
private readonly Func<IDtoService> _dtoServiceFactory;
|
|
private readonly Func<IDtoService> _dtoServiceFactory;
|
|
private readonly Func<IConnectManager> _connectFactory;
|
|
private readonly Func<IConnectManager> _connectFactory;
|
|
private readonly Func<IChannelManager> _channelManager;
|
|
private readonly Func<IChannelManager> _channelManager;
|
|
|
|
+ private readonly Func<ILibraryManager> _libraryManager;
|
|
private readonly IServerApplicationHost _appHost;
|
|
private readonly IServerApplicationHost _appHost;
|
|
private readonly IFileSystem _fileSystem;
|
|
private readonly IFileSystem _fileSystem;
|
|
|
|
|
|
- public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func<IChannelManager> channelManager)
|
|
|
|
|
|
+ public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func<IChannelManager> channelManager, Func<ILibraryManager> libraryManager)
|
|
{
|
|
{
|
|
_logger = logger;
|
|
_logger = logger;
|
|
UserRepository = userRepository;
|
|
UserRepository = userRepository;
|
|
@@ -89,6 +90,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
_jsonSerializer = jsonSerializer;
|
|
_jsonSerializer = jsonSerializer;
|
|
_fileSystem = fileSystem;
|
|
_fileSystem = fileSystem;
|
|
_channelManager = channelManager;
|
|
_channelManager = channelManager;
|
|
|
|
+ _libraryManager = libraryManager;
|
|
ConfigurationManager = configurationManager;
|
|
ConfigurationManager = configurationManager;
|
|
Users = new List<User>();
|
|
Users = new List<User>();
|
|
|
|
|
|
@@ -173,6 +175,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
{
|
|
{
|
|
await DoPolicyMigration(user).ConfigureAwait(false);
|
|
await DoPolicyMigration(user).ConfigureAwait(false);
|
|
await DoChannelMigration(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
|
|
// 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)
|
|
public UserDto GetUserDto(User user, string remoteEndPoint = null)
|
|
{
|
|
{
|
|
if (user == null)
|
|
if (user == null)
|