fix query by multiple ids

This commit is contained in:
Luke Pulverenti 2016-03-20 17:32:26 -04:00
parent f4d61ddcc6
commit a2a0e1ae75
3 changed files with 38 additions and 11 deletions

View File

@ -167,7 +167,7 @@ namespace MediaBrowser.Controller.Entities
{
lock (_childrenSyncLock)
{
var newChildren = _children.ToList();
var newChildren = ChildIds.ToList();
newChildren.AddRange(children);
_children = newChildren.ToList();
}
@ -176,11 +176,11 @@ namespace MediaBrowser.Controller.Entities
{
lock (_childrenSyncLock)
{
if (!_children.Contains(child))
var childIds = ChildIds.ToList();
if (!childIds.Contains(child))
{
var newChildren = _children.ToList();
newChildren.Add(child);
_children = newChildren.ToList();
childIds.Add(child);
_children = childIds.ToList();
}
}
}
@ -189,7 +189,7 @@ namespace MediaBrowser.Controller.Entities
{
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.
/// </summary>
/// <value>The actual children.</value>
protected virtual IEnumerable<BaseItem> ActualChildren
protected virtual IEnumerable<Guid> ChildIds
{
get
{
@ -267,11 +267,23 @@ namespace MediaBrowser.Controller.Entities
{
_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>
/// thread-safe access to the actual children of this folder - without regard to user
/// </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)
{
Logger.Debug("Query requires post-filtering due to PersonIds");

View File

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

View File

@ -369,9 +369,14 @@ namespace MediaBrowser.Server.Implementations.Library
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}",
item.GetType().Name,
item.Name,
item.Name ?? "Unknown name",
item.Path ?? string.Empty,
item.Id);