fixes #305 - Multiple collections

pull/702/head
Luke Pulverenti 11 years ago
parent 398b658dbe
commit 7a5ba39603

@ -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 later
if (newPath.Equals(existingPath, StringComparison.OrdinalIgnoreCase))
@ -211,12 +210,6 @@ namespace MediaBrowser.Api.Library
return true;
}
// Validate the D:\Movies\Kids scenario
if (newPath.StartsWith(existingPath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
return false;
}
// Validate the D:\ scenario
if (existingPath.StartsWith(newPath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{

@ -384,6 +384,18 @@ namespace MediaBrowser.Controller.Entities
var 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 dates

@ -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));

@ -430,6 +430,18 @@ namespace MediaBrowser.Server.Implementations.Library
var 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

Loading…
Cancel
Save