fix query by multiple ids

pull/702/head
Luke Pulverenti 9 years ago
parent f4d61ddcc6
commit a2a0e1ae75

@ -167,7 +167,7 @@ namespace MediaBrowser.Controller.Entities
{ {
lock (_childrenSyncLock) lock (_childrenSyncLock)
{ {
var newChildren = _children.ToList(); var newChildren = ChildIds.ToList();
newChildren.AddRange(children); newChildren.AddRange(children);
_children = newChildren.ToList(); _children = newChildren.ToList();
} }
@ -176,11 +176,11 @@ namespace MediaBrowser.Controller.Entities
{ {
lock (_childrenSyncLock) lock (_childrenSyncLock)
{ {
if (!_children.Contains(child)) var childIds = ChildIds.ToList();
if (!childIds.Contains(child))
{ {
var newChildren = _children.ToList(); childIds.Add(child);
newChildren.Add(child); _children = childIds.ToList();
_children = newChildren.ToList();
} }
} }
} }
@ -189,7 +189,7 @@ namespace MediaBrowser.Controller.Entities
{ {
lock (_childrenSyncLock) lock (_childrenSyncLock)
{ {
_children = _children.Except(children).ToList(); _children = ChildIds.Except(children).ToList();
} }
} }
@ -257,7 +257,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the actual children. /// Gets or sets the actual children.
/// </summary> /// </summary>
/// <value>The actual children.</value> /// <value>The actual children.</value>
protected virtual IEnumerable<BaseItem> ActualChildren protected virtual IEnumerable<Guid> ChildIds
{ {
get get
{ {
@ -267,11 +267,23 @@ namespace MediaBrowser.Controller.Entities
{ {
_children = LoadChildren().ToList(); _children = LoadChildren().ToList();
} }
return _children.Select(LibraryManager.GetItemById).Where(i => i != null); return _children.ToList();
} }
} }
} }
/// <summary>
/// Gets the actual children.
/// </summary>
/// <value>The actual children.</value>
protected virtual IEnumerable<BaseItem> ActualChildren
{
get
{
return ChildIds.Select(LibraryManager.GetItemById).Where(i => i != null);
}
}
/// <summary> /// <summary>
/// thread-safe access to the actual children of this folder - without regard to user /// thread-safe access to the actual children of this folder - without regard to user
/// </summary> /// </summary>
@ -912,6 +924,12 @@ namespace MediaBrowser.Controller.Entities
} }
} }
if (query.ItemIds.Length > 0)
{
Logger.Debug("Query requires post-filtering due to ItemIds");
return true;
}
if (query.PersonIds.Length > 0) if (query.PersonIds.Length > 0)
{ {
Logger.Debug("Query requires post-filtering due to PersonIds"); Logger.Debug("Query requires post-filtering due to PersonIds");

@ -55,7 +55,7 @@ namespace MediaBrowser.Server.Implementations.Channels
} }
await CleanDatabase(cancellationToken).ConfigureAwait(false); await CleanDatabase(cancellationToken).ConfigureAwait(false);
progress.Report(100); progress.Report(100);
} }
@ -167,10 +167,14 @@ namespace MediaBrowser.Server.Implementations.Channels
{ {
var item = _libraryManager.GetItemById(id); var item = _libraryManager.GetItemById(id);
if (item == null)
{
return Task.FromResult(true);
}
return _libraryManager.DeleteItem(item, new DeleteOptions return _libraryManager.DeleteItem(item, new DeleteOptions
{ {
DeleteFileLocation = false DeleteFileLocation = false
}); });
} }

@ -369,9 +369,14 @@ namespace MediaBrowser.Server.Implementations.Library
public async Task DeleteItem(BaseItem item, DeleteOptions options) public async Task DeleteItem(BaseItem item, DeleteOptions options)
{ {
if (item == null)
{
throw new ArgumentNullException("item");
}
_logger.Debug("Deleting item, Type: {0}, Name: {1}, Path: {2}, Id: {3}", _logger.Debug("Deleting item, Type: {0}, Name: {1}, Path: {2}, Id: {3}",
item.GetType().Name, item.GetType().Name,
item.Name, item.Name ?? "Unknown name",
item.Path ?? string.Empty, item.Path ?? string.Empty,
item.Id); item.Id);

Loading…
Cancel
Save