diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 5b90382b6b..fba8732512 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -103,7 +103,33 @@ namespace MediaBrowser.Controller.Entities await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); - await ItemRepository.SaveChildren(Id, _children.ToList().Select(i => i.Id), cancellationToken).ConfigureAwait(false); + await ItemRepository.SaveChildren(Id, _children.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false); + } + + protected void AddChildrenInternal(IEnumerable children) + { + foreach (var child in children) + { + _children.Add(child); + } + } + + protected void RemoveChildrenInternal(IEnumerable children) + { + lock (ChildrenSyncLock) + { + _children = new ConcurrentBag(_children.Except(children)); + } + } + + protected void ClearChildrenInternal() + { + BaseItem removed; + + while (_children.TryTake(out removed)) + { + + } } /// @@ -132,22 +158,13 @@ namespace MediaBrowser.Controller.Entities /// Unable to remove + item.Name public Task RemoveChild(BaseItem item, CancellationToken cancellationToken) { - List newChildren; - - lock (ChildrenSyncLock) - { - newChildren = _children.ToList(); - - newChildren.Remove(item); - - _children = new ConcurrentBag(newChildren); - } + RemoveChildrenInternal(new[] { item }); item.Parent = null; LibraryManager.ReportItemRemoved(item); - return ItemRepository.SaveChildren(Id, newChildren.Select(i => i.Id), cancellationToken); + return ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken); } #region Indexing @@ -726,7 +743,7 @@ namespace MediaBrowser.Controller.Entities Logger.Debug("** " + item.Name + " Added to library."); } - await ItemRepository.SaveChildren(Id, _children.ToList().Select(i => i.Id), cancellationToken).ConfigureAwait(false); + await ItemRepository.SaveChildren(Id, _children.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false); //force the indexes to rebuild next time if (IndexCache != null) diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 6b21d20a84..00c31ba5e2 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.202 + 3.0.203 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 0f83c0e7a2..94d3b61312 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.202 + 3.0.203 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 8a0f19414d..72aa871bfb 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.202 + 3.0.203 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +