diff options
| author | HurricaneHernandez <carlos@techbyte.ca> | 2014-10-24 16:12:24 -0600 |
|---|---|---|
| committer | HurricaneHernandez <carlos@techbyte.ca> | 2014-10-24 16:12:24 -0600 |
| commit | e01f932f4bd6764850155616e733590a74d905be (patch) | |
| tree | 894a2da0c7b9d96d5108b6f2ed57e0f10dfee96a /MediaBrowser.Server.Implementations/Library | |
| parent | 3be4aa8dc729f5899658790f43a1d1c182e7a243 (diff) | |
| parent | c8a735bcb1ba71e9501d18b3044aa30793ff97ee (diff) | |
Merge remote-tracking branch 'upstream/master' into docker
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library')
4 files changed, 38 insertions, 39 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs index e902b939b..d3d71e0f9 100644 --- a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs +++ b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs @@ -3,7 +3,6 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Resolvers; using System; -using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 71e1b1087..13ea7fb44 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -530,20 +530,12 @@ namespace MediaBrowser.Server.Implementations.Library return item; } - public BaseItem ResolvePath(FileSystemInfo fileInfo, Folder parent = null) + public BaseItem ResolvePath(FileSystemInfo fileInfo, Folder parent = null, string collectionType = null) { - return ResolvePath(fileInfo, new DirectoryService(_logger), parent); + return ResolvePath(fileInfo, new DirectoryService(_logger), parent, collectionType); } - /// <summary> - /// Resolves a path into a BaseItem - /// </summary> - /// <param name="fileInfo">The file info.</param> - /// <param name="directoryService">The directory service.</param> - /// <param name="parent">The parent.</param> - /// <returns>BaseItem.</returns> - /// <exception cref="System.ArgumentNullException">fileInfo</exception> - public BaseItem ResolvePath(FileSystemInfo fileInfo, IDirectoryService directoryService, Folder parent = null) + public BaseItem ResolvePath(FileSystemInfo fileInfo, IDirectoryService directoryService, Folder parent = null, string collectionType = null) { if (fileInfo == null) { @@ -554,7 +546,8 @@ namespace MediaBrowser.Server.Implementations.Library { Parent = parent, Path = fileInfo.FullName, - FileInfo = fileInfo + FileInfo = fileInfo, + CollectionType = collectionType }; // Return null if ignore rules deem that we should do so @@ -622,15 +615,7 @@ namespace MediaBrowser.Server.Implementations.Library return !args.ContainsFileSystemEntryByName(".ignore"); } - /// <summary> - /// Resolves a set of files into a list of BaseItem - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="files">The files.</param> - /// <param name="directoryService">The directory service.</param> - /// <param name="parent">The parent.</param> - /// <returns>List{``0}.</returns> - public List<T> ResolvePaths<T>(IEnumerable<FileSystemInfo> files, IDirectoryService directoryService, Folder parent) + public List<T> ResolvePaths<T>(IEnumerable<FileSystemInfo> files, IDirectoryService directoryService, Folder parent, string collectionType = null) where T : BaseItem { var list = new List<T>(); @@ -639,7 +624,7 @@ namespace MediaBrowser.Server.Implementations.Library { try { - var item = ResolvePath(f, directoryService, parent) as T; + var item = ResolvePath(f, directoryService, parent, collectionType) as T; if (item != null) { @@ -1190,6 +1175,20 @@ namespace MediaBrowser.Server.Implementations.Library return item; } + public BaseItem GetMemoryItemById(Guid id) + { + if (id == Guid.Empty) + { + throw new ArgumentNullException("id"); + } + + BaseItem item; + + LibraryItemsCache.TryGetValue(id, out item); + + return item; + } + /// <summary> /// Gets the intros. /// </summary> @@ -1497,14 +1496,10 @@ namespace MediaBrowser.Server.Implementations.Library return null; } - var collectionTypes = _userManager.Users - .Select(i => i.RootFolder) - .Distinct() - .SelectMany(i => i.Children) + var collectionTypes = GetUserRootFolder().Children .OfType<ICollectionFolder>() - .Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path)) + .Where(i => !string.IsNullOrEmpty(i.CollectionType) && (string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path))) .Select(i => i.CollectionType) - .Where(i => !string.IsNullOrEmpty(i)) .Distinct() .ToList(); diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 7f15dce2d..231b807d8 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -82,29 +82,29 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies { if (string.Equals(collectionType, CollectionType.Trailers, StringComparison.OrdinalIgnoreCase)) { - return FindMovie<Trailer>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, false, false); + return FindMovie<Trailer>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, false, false, collectionType); } if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { - return FindMovie<MusicVideo>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, false, false); + return FindMovie<MusicVideo>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, false, false, collectionType); } if (string.Equals(collectionType, CollectionType.AdultVideos, StringComparison.OrdinalIgnoreCase)) { - return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, false); + return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, false, collectionType); } if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) { - return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, false); + return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, false, collectionType); } if (string.IsNullOrEmpty(collectionType) || string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.Equals(collectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)) { - return FindMovie<Movie>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, true); + return FindMovie<Movie>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, true, collectionType); } return null; @@ -190,7 +190,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies /// <param name="directoryService">The directory service.</param> /// <param name="supportMultiFileItems">if set to <c>true</c> [support multi file items].</param> /// <returns>Movie.</returns> - private T FindMovie<T>(string path, Folder parent, List<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, bool supportMultiFileItems, bool supportsMultipleSources) + private T FindMovie<T>(string path, Folder parent, List<FileSystemInfo> fileSystemEntries, IDirectoryService directoryService, bool supportMultiFileItems, bool supportsMultipleSources, string collectionType) where T : Video, new() { var movies = new List<T>(); @@ -239,7 +239,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies { FileInfo = child, Path = child.FullName, - Parent = parent + Parent = parent, + CollectionType = collectionType }; var item = ResolveVideo<T>(childArgs); diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 86c908d05..f96d9882d 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Events; +using MediaBrowser.Common; +using MediaBrowser.Common.Events; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; @@ -64,6 +65,7 @@ namespace MediaBrowser.Server.Implementations.Library private readonly Func<IImageProcessor> _imageProcessorFactory; private readonly Func<IDtoService> _dtoServiceFactory; private readonly Func<IConnectManager> _connectFactory; + private readonly IApplicationHost _appHost; /// <summary> /// Initializes a new instance of the <see cref="UserManager" /> class. @@ -71,7 +73,7 @@ namespace MediaBrowser.Server.Implementations.Library /// <param name="logger">The logger.</param> /// <param name="configurationManager">The configuration manager.</param> /// <param name="userRepository">The user repository.</param> - public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory) + public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IApplicationHost appHost) { _logger = logger; UserRepository = userRepository; @@ -80,6 +82,7 @@ namespace MediaBrowser.Server.Implementations.Library _imageProcessorFactory = imageProcessorFactory; _dtoServiceFactory = dtoServiceFactory; _connectFactory = connectFactory; + _appHost = appHost; ConfigurationManager = configurationManager; Users = new List<User>(); } @@ -298,7 +301,8 @@ namespace MediaBrowser.Server.Implementations.Library Configuration = user.Configuration, ConnectLinkType = user.ConnectLinkType, ConnectUserId = user.ConnectUserId, - ConnectUserName = user.ConnectUserName + ConnectUserName = user.ConnectUserName, + ServerId = _appHost.SystemId }; var image = user.GetImageInfo(ImageType.Primary, 0); |
