Added Add/Remove/Clear Children protected methods

pull/702/head
Luke Pulverenti 11 years ago
parent 4a1d8771a8
commit 04468452ea

@ -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<BaseItem> children)
{
foreach (var child in children)
{
_children.Add(child);
}
}
protected void RemoveChildrenInternal(IEnumerable<BaseItem> children)
{
lock (ChildrenSyncLock)
{
_children = new ConcurrentBag<BaseItem>(_children.Except(children));
}
}
protected void ClearChildrenInternal()
{
BaseItem removed;
while (_children.TryTake(out removed))
{
}
}
/// <summary>
@ -132,22 +158,13 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="System.InvalidOperationException">Unable to remove + item.Name</exception>
public Task RemoveChild(BaseItem item, CancellationToken cancellationToken)
{
List<BaseItem> newChildren;
lock (ChildrenSyncLock)
{
newChildren = _children.ToList();
newChildren.Remove(item);
_children = new ConcurrentBag<BaseItem>(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)

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.202</version>
<version>3.0.203</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.202" />
<dependency id="MediaBrowser.Common" version="3.0.203" />
<dependency id="NLog" version="2.0.1.2" />
<dependency id="ServiceStack.Text" version="3.9.58" />
<dependency id="SimpleInjector" version="2.3.2" />

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.202</version>
<version>3.0.203</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.202</version>
<version>3.0.203</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.202" />
<dependency id="MediaBrowser.Common" version="3.0.203" />
</dependencies>
</metadata>
<files>

Loading…
Cancel
Save