removed dead code
This commit is contained in:
parent
23fe6dc4be
commit
95250b9f22
|
@ -151,16 +151,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
AddChildInternal(item.Id);
|
||||
|
||||
await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!EnableNewFolderQuerying())
|
||||
{
|
||||
await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool EnableNewFolderQuerying()
|
||||
{
|
||||
return ConfigurationManager.Configuration.MigrationVersion >= 1;
|
||||
}
|
||||
|
||||
protected void AddChildrenInternal(List<Guid> children)
|
||||
|
@ -197,21 +187,11 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// Removes the child.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <exception cref="System.InvalidOperationException">Unable to remove + item.Name</exception>
|
||||
public Task RemoveChild(BaseItem item, CancellationToken cancellationToken)
|
||||
public void RemoveChild(BaseItem item)
|
||||
{
|
||||
RemoveChildrenInternal(new[] { item.Id }.ToList());
|
||||
|
||||
item.SetParent(null);
|
||||
|
||||
if (!EnableNewFolderQuerying())
|
||||
{
|
||||
return ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken);
|
||||
}
|
||||
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
#region Indexing
|
||||
|
@ -500,11 +480,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
await LibraryManager.CreateItems(newItems, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
AddChildrenInternal(newItems.Select(i => i.Id).ToList());
|
||||
|
||||
if (!EnableNewFolderQuerying())
|
||||
{
|
||||
await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,45 +709,11 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||
protected IEnumerable<Guid> GetCachedChildren()
|
||||
{
|
||||
if (EnableNewFolderQuerying())
|
||||
return ItemRepository.GetItemIdsList(new InternalItemsQuery
|
||||
{
|
||||
return ItemRepository.GetItemIdsList(new InternalItemsQuery
|
||||
{
|
||||
ParentId = Id
|
||||
ParentId = Id
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return ItemRepository.GetChildrenItems(Id).Select(RetrieveChild).Where(i => i != null).Select(i => i.Id);
|
||||
}
|
||||
|
||||
private BaseItem RetrieveChild(BaseItem child)
|
||||
{
|
||||
if (child == null || child.Id == Guid.Empty)
|
||||
{
|
||||
Logger.Error("Item found with empty Id: " + (child.Path ?? child.Name));
|
||||
return null;
|
||||
}
|
||||
|
||||
var item = LibraryManager.GetMemoryItemById(child.Id);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
if (item is IByReferenceItem)
|
||||
{
|
||||
return LibraryManager.GetOrAddByReferenceItem(item);
|
||||
}
|
||||
|
||||
item.SetParent(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
child.SetParent(this);
|
||||
LibraryManager.RegisterItem(child);
|
||||
item = child;
|
||||
}
|
||||
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
public QueryResult<BaseItem> QueryRecursive(InternalItemsQuery query)
|
||||
|
|
|
@ -42,13 +42,6 @@ namespace MediaBrowser.Controller.Persistence
|
|||
/// <returns>Task{IEnumerable{ItemReview}}.</returns>
|
||||
IEnumerable<ItemReview> GetCriticReviews(Guid itemId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the children items.
|
||||
/// </summary>
|
||||
/// <param name="parentId">The parent identifier.</param>
|
||||
/// <returns>IEnumerable<BaseItem>.</returns>
|
||||
IEnumerable<BaseItem> GetChildrenItems(Guid parentId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the critic reviews.
|
||||
/// </summary>
|
||||
|
@ -96,22 +89,6 @@ namespace MediaBrowser.Controller.Persistence
|
|||
/// <returns>Task.</returns>
|
||||
Task SaveChapters(Guid id, IEnumerable<ChapterInfo> chapters, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the children.
|
||||
/// </summary>
|
||||
/// <param name="parentId">The parent id.</param>
|
||||
/// <returns>IEnumerable{ChildDefinition}.</returns>
|
||||
IEnumerable<Guid> GetChildren(Guid parentId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the children.
|
||||
/// </summary>
|
||||
/// <param name="parentId">The parent id.</param>
|
||||
/// <param name="children">The children.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveChildren(Guid parentId, IEnumerable<Guid> children, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the media streams.
|
||||
/// </summary>
|
||||
|
|
|
@ -421,7 +421,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
|
||||
if (saveLocally)
|
||||
{
|
||||
if (item is Episode)
|
||||
if (type == ImageType.Primary && item is Episode)
|
||||
{
|
||||
path = Path.Combine(Path.GetDirectoryName(item.Path), "metadata", filename + extension);
|
||||
}
|
||||
|
|
|
@ -430,7 +430,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
}
|
||||
else if (parent != null)
|
||||
{
|
||||
await parent.RemoveChild(item, CancellationToken.None).ConfigureAwait(false);
|
||||
parent.RemoveChild(item);
|
||||
}
|
||||
|
||||
await ItemRepository.DeleteItem(item.Id, CancellationToken.None).ConfigureAwait(false);
|
||||
|
|
|
@ -63,8 +63,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
|
||||
private readonly string _criticReviewsPath;
|
||||
|
||||
private IDbCommand _deleteChildrenCommand;
|
||||
private IDbCommand _saveChildrenCommand;
|
||||
private IDbCommand _deleteItemCommand;
|
||||
|
||||
private IDbCommand _deletePeopleCommand;
|
||||
|
@ -138,9 +136,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
"create index if not exists idx_AncestorIds1 on AncestorIds(AncestorId)",
|
||||
"create index if not exists idx_AncestorIds2 on AncestorIds(AncestorIdText)",
|
||||
|
||||
"create table if not exists ChildrenIds (ParentId GUID, ItemId GUID, PRIMARY KEY (ParentId, ItemId))",
|
||||
"create index if not exists idx_ChildrenIds on ChildrenIds(ParentId,ItemId)",
|
||||
|
||||
"create table if not exists People (ItemId GUID, Name TEXT NOT NULL, Role TEXT, PersonType TEXT, SortOrder int, ListOrder int)",
|
||||
"create index if not exists idxPeopleItemId on People(ItemId)",
|
||||
"create index if not exists idxPeopleName on People(Name)",
|
||||
|
@ -477,19 +472,10 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
}
|
||||
_saveItemCommand.CommandText += ")";
|
||||
|
||||
_deleteChildrenCommand = _connection.CreateCommand();
|
||||
_deleteChildrenCommand.CommandText = "delete from ChildrenIds where ParentId=@ParentId";
|
||||
_deleteChildrenCommand.Parameters.Add(_deleteChildrenCommand, "@ParentId");
|
||||
|
||||
_deleteItemCommand = _connection.CreateCommand();
|
||||
_deleteItemCommand.CommandText = "delete from TypedBaseItems where guid=@Id";
|
||||
_deleteItemCommand.Parameters.Add(_deleteItemCommand, "@Id");
|
||||
|
||||
_saveChildrenCommand = _connection.CreateCommand();
|
||||
_saveChildrenCommand.CommandText = "replace into ChildrenIds (ParentId, ItemId) values (@ParentId, @ItemId)";
|
||||
_saveChildrenCommand.Parameters.Add(_saveChildrenCommand, "@ParentId");
|
||||
_saveChildrenCommand.Parameters.Add(_saveChildrenCommand, "@ItemId");
|
||||
|
||||
// People
|
||||
_deletePeopleCommand = _connection.CreateCommand();
|
||||
_deletePeopleCommand.CommandText = "delete from People where ItemId=@Id";
|
||||
|
@ -1375,63 +1361,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Guid> GetChildren(Guid parentId)
|
||||
{
|
||||
if (parentId == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("parentId");
|
||||
}
|
||||
|
||||
CheckDisposed();
|
||||
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "select ItemId from ChildrenIds where ParentId = @ParentId";
|
||||
|
||||
cmd.Parameters.Add(cmd, "@ParentId", DbType.Guid).Value = parentId;
|
||||
|
||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
yield return reader.GetGuid(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetChildrenItems(Guid parentId)
|
||||
{
|
||||
if (parentId == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("parentId");
|
||||
}
|
||||
|
||||
CheckDisposed();
|
||||
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "select " + string.Join(",", _retriveItemColumns) + " from TypedBaseItems where guid in (select ItemId from ChildrenIds where ParentId = @ParentId)";
|
||||
|
||||
cmd.Parameters.Add(cmd, "@ParentId", DbType.Guid).Value = parentId;
|
||||
|
||||
//Logger.Debug(cmd.CommandText);
|
||||
|
||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
var item = GetItem(reader);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetItemsOfType(Type type)
|
||||
{
|
||||
if (type == null)
|
||||
|
@ -2392,11 +2321,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
{
|
||||
transaction = _connection.BeginTransaction();
|
||||
|
||||
// First delete children
|
||||
_deleteChildrenCommand.GetParameter(0).Value = id;
|
||||
_deleteChildrenCommand.Transaction = transaction;
|
||||
_deleteChildrenCommand.ExecuteNonQuery();
|
||||
|
||||
// Delete people
|
||||
_deletePeopleCommand.GetParameter(0).Value = id;
|
||||
_deletePeopleCommand.Transaction = transaction;
|
||||
|
@ -2455,79 +2379,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
}
|
||||
}
|
||||
|
||||
public async Task SaveChildren(Guid parentId, IEnumerable<Guid> children, CancellationToken cancellationToken)
|
||||
{
|
||||
if (parentId == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("parentId");
|
||||
}
|
||||
|
||||
if (children == null)
|
||||
{
|
||||
throw new ArgumentNullException("children");
|
||||
}
|
||||
|
||||
CheckDisposed();
|
||||
|
||||
await WriteLock.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
IDbTransaction transaction = null;
|
||||
|
||||
try
|
||||
{
|
||||
transaction = _connection.BeginTransaction();
|
||||
|
||||
// First delete
|
||||
_deleteChildrenCommand.GetParameter(0).Value = parentId;
|
||||
_deleteChildrenCommand.Transaction = transaction;
|
||||
|
||||
_deleteChildrenCommand.ExecuteNonQuery();
|
||||
|
||||
foreach (var id in children)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
_saveChildrenCommand.GetParameter(0).Value = parentId;
|
||||
_saveChildrenCommand.GetParameter(1).Value = id;
|
||||
|
||||
_saveChildrenCommand.Transaction = transaction;
|
||||
|
||||
_saveChildrenCommand.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
if (transaction != null)
|
||||
{
|
||||
transaction.Rollback();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorException("Failed to save children:", e);
|
||||
|
||||
if (transaction != null)
|
||||
{
|
||||
transaction.Rollback();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (transaction != null)
|
||||
{
|
||||
transaction.Dispose();
|
||||
}
|
||||
|
||||
WriteLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> GetPeopleNames(InternalPeopleQuery query)
|
||||
{
|
||||
if (query == null)
|
||||
|
|
Loading…
Reference in New Issue
Block a user