The Free Software Media System - Server Backend & API
fixes #305 - Multiple collections
Luke Pulverenti7a5ba39603c2
diff --git a/MediaBrowser.Api/Library/LibraryHelpers.cs b/MediaBrowser.Api/Library/LibraryHelpers.csindex ff0915d78f..d3b7861a67 100644--- a/MediaBrowser.Api/Library/LibraryHelpers.cs+++ b/MediaBrowser.Api/Library/LibraryHelpers.cs@@ -203,7 +203,6 @@ namespace MediaBrowser.Api.Library{// Example: D:\Movies is the existing path// D:\ cannot be added- // Neither can D:\Movies\Kids// A D:\Movies duplicate is ok here since that will be caught laterif (newPath.Equals(existingPath, StringComparison.OrdinalIgnoreCase))@@ -211,12 +210,6 @@ namespace MediaBrowser.Api.Libraryreturn true;}- // Validate the D:\Movies\Kids scenario- if (newPath.StartsWith(existingPath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))- {- return false;- }-// Validate the D:\ scenarioif (existingPath.StartsWith(newPath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)){diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex ac8688f77e..8982801106 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -384,6 +384,18 @@ namespace MediaBrowser.Controller.Entitiesvar flattenFolderDepth = isPhysicalRoot ? 2 : 0;args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, Logger, flattenFolderDepth: flattenFolderDepth, args: args, resolveShortcuts: isPhysicalRoot || args.IsVf);++ // Need to remove subpaths that may have been resolved from shortcuts+ // Example: if \\server\movies exists, then strip out \\server\movies\action+ if (isPhysicalRoot)+ {+ var paths = args.FileSystemDictionary.Keys.ToList();++ foreach (var subPath in paths.Where(subPath => paths.Any(i => subPath.StartsWith(i.TrimEnd(System.IO.Path.DirectorySeparatorChar) + System.IO.Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))))+ {+ args.FileSystemDictionary.Remove(subPath);+ }+ }}//update our datesdiff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.csindex 64e5da92e7..723ab47562 100644--- a/MediaBrowser.Controller/Entities/CollectionFolder.cs+++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs@@ -1,5 +1,4 @@using MediaBrowser.Common.Extensions;-using MediaBrowser.Model.Entities;using System;using System.Collections.Concurrent;using System.Collections.Generic;@@ -74,23 +73,25 @@ namespace MediaBrowser.Controller.Entities{get{- IEnumerable<Guid> folderIds;+ Dictionary<Guid,Guid> folderIds;try{// Accessing ResolveArgs could involve file system access- folderIds = ResolveArgs.PhysicalLocations.Select(f => (f.GetMBId(typeof(Folder))));+ folderIds = ResolveArgs.PhysicalLocations+ .Select(f => (f.GetMBId(typeof(Folder))))+ .ToDictionary(i => i);}catch (IOException ex){Logger.ErrorException("Error creating FolderIds for {0}", ex, Path);- folderIds = new Guid[] {};+ folderIds = new Dictionary<Guid, Guid>();}var ourChildren =- LibraryManager.RootFolder.Children.OfType<Folder>()- .Where(i => folderIds.Contains(i.Id))+ LibraryManager.RootFolder.RecursiveChildren.OfType<Folder>()+ .Where(i => folderIds.ContainsKey(i.Id)).SelectMany(c => c.Children);return new ConcurrentDictionary<Guid,BaseItem>(ourChildren.ToDictionary(i => i.Id));diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.csindex 13857a656e..af0212738c 100644--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs@@ -430,6 +430,18 @@ namespace MediaBrowser.Server.Implementations.Libraryvar flattenFolderDepth = isPhysicalRoot ? 2 : 0;args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, _logger, flattenFolderDepth: flattenFolderDepth, args: args, resolveShortcuts: isPhysicalRoot || args.IsVf);++ // Need to remove subpaths that may have been resolved from shortcuts+ // Example: if \\server\movies exists, then strip out \\server\movies\action+ if (isPhysicalRoot)+ {+ var paths = args.FileSystemDictionary.Keys.ToList();++ foreach (var subPath in paths.Where(subPath => paths.Any(i => subPath.StartsWith(i.TrimEnd(System.IO.Path.DirectorySeparatorChar) + System.IO.Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))))+ {+ args.FileSystemDictionary.Remove(subPath);+ }+ }}// Check to see if we should resolve based on our contents