aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/Library/LibraryHelpers.cs4
-rw-r--r--MediaBrowser.Controller/Entities/CollectionFolder.cs2
-rw-r--r--MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs21
3 files changed, 23 insertions, 4 deletions
diff --git a/MediaBrowser.Api/Library/LibraryHelpers.cs b/MediaBrowser.Api/Library/LibraryHelpers.cs
index 8abdc4df5..ab7449273 100644
--- a/MediaBrowser.Api/Library/LibraryHelpers.cs
+++ b/MediaBrowser.Api/Library/LibraryHelpers.cs
@@ -182,6 +182,8 @@ namespace MediaBrowser.Api.Library
throw new ArgumentException(string.Format("The path cannot be added to the library because {0} already exists.", duplicate));
}
+ // Don't allow duplicate sub-paths within the same user library, or it will result in duplicate items
+ // See comments in IsNewPathValid
duplicate = Directory.EnumerateFiles(currentViewRootFolderPath, "*.lnk", SearchOption.AllDirectories)
.Select(FileSystem.ResolveShortcut)
.FirstOrDefault(p => !IsNewPathValid(mediaPath, p, true));
@@ -221,7 +223,7 @@ namespace MediaBrowser.Api.Library
return true;
}
- // Validate the D:\Movies\Kids scenario
+ // If enforceSubPathRestriction is true, validate the D:\Movies\Kids scenario
if (enforceSubPathRestriction && newPath.StartsWith(existingPath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
return false;
diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs
index 723ab4756..4574ca3e9 100644
--- a/MediaBrowser.Controller/Entities/CollectionFolder.cs
+++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs
@@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.Entities
{
// Accessing ResolveArgs could involve file system access
folderIds = ResolveArgs.PhysicalLocations
- .Select(f => (f.GetMBId(typeof(Folder))))
+ .Select(f => f.GetMBId(typeof(Folder)))
.ToDictionary(i => i);
}
catch (IOException ex)
diff --git a/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs b/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs
index 104b09fda..a59b15257 100644
--- a/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs
+++ b/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs
@@ -249,7 +249,7 @@ namespace MediaBrowser.ServerApplication.EntryPoints
/// <param name="collections">The collections.</param>
/// <param name="allRecursiveChildren">All recursive children.</param>
/// <returns>IEnumerable{``0}.</returns>
- private IEnumerable<T> TranslatePhysicalItemToUserLibrary<T>(T item, User user, List<BaseItem> collections, Dictionary<Guid, BaseItem> allRecursiveChildren)
+ private IEnumerable<T> TranslatePhysicalItemToUserLibrary<T>(T item, User user, IEnumerable<BaseItem> collections, Dictionary<Guid, BaseItem> allRecursiveChildren)
where T : BaseItem
{
// If the physical root changed, return the user root
@@ -261,7 +261,24 @@ namespace MediaBrowser.ServerApplication.EntryPoints
// Need to find what user collection folder this belongs to
if (item.Parent is AggregateFolder)
{
- return new T[] { user.RootFolder as T };
+ if (item.LocationType == LocationType.FileSystem)
+ {
+ return collections.Where(i =>
+ {
+
+ try
+ {
+ return i.LocationType == LocationType.FileSystem &&
+ i.ResolveArgs.PhysicalLocations.Contains(item.Path);
+ }
+ catch (Exception ex)
+ {
+ _logger.ErrorException("Error getting ResolveArgs for {0}", ex, i.Path);
+ return false;
+ }
+
+ }).Cast<T>();
+ }
}
// If it's a user root, return it only if it's the right one