ItemsCollection on Container
This commit is contained in:
@@ -111,13 +111,12 @@ public class CopyCommand : CommandBase, ITransportationCommand
|
||||
|
||||
if (item is IContainer container)
|
||||
{
|
||||
if (!((await resolvedTarget.Items.GetItemsAsync())?.Any(i => i.Path.GetName() == item.Name) ?? false))
|
||||
if (resolvedTarget.ItemsCollection.All(i => i.Path.GetName() != item.Name))
|
||||
{
|
||||
await copyOperation.CreateContainerAsync(resolvedTarget, container.Name, container.PointInTime);
|
||||
}
|
||||
|
||||
var children = await container.Items.GetItemsAsync();
|
||||
if (children is null) continue;
|
||||
var children = container.ItemsCollection;
|
||||
|
||||
await TraverseTree(currentTime, children.Select(c => c.Path).ToList(), target.GetChild(item.Name, AbsolutePathType.Container), transportMode, copyOperation);
|
||||
await copyOperation.ContainerCopyDoneAsync(new AbsolutePath(_timelessContentProvider, container));
|
||||
|
||||
@@ -42,9 +42,7 @@ public abstract class CreateItemBase : CommandBase, IExecutableCommand, IInitabl
|
||||
var parent = await ResolveParentAsync();
|
||||
if (parent is not IContainer parentContainer) return CanCommandRun.False;
|
||||
|
||||
var items = await parentContainer.Items.GetItemsAsync().AwaitWithTimeout(10, Enumerable.Empty<AbsolutePath>());
|
||||
if (items is null) return CanCommandRun.Forcable;
|
||||
|
||||
var items = parentContainer.ItemsCollection;
|
||||
var existingItem = items.FirstOrDefault(i => i.Path.GetName() == NewItemName);
|
||||
|
||||
return existingItem switch
|
||||
|
||||
@@ -71,7 +71,7 @@ public class DeleteCommand : CommandBase, IExecutableCommand
|
||||
{
|
||||
await TraverseTree(
|
||||
currentTime,
|
||||
(await container.Items.GetItemsAsync())?.Select(i => i.Path) ?? Enumerable.Empty<FullName>(),
|
||||
container.ItemsCollection.Select(i => i.Path),
|
||||
itemDeleters,
|
||||
deleteStrategy
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@ public static class Helper
|
||||
{
|
||||
public static async Task<string?> GetNewNameAsync(IContainer resolvedTarget, string name, TransportMode transportMode)
|
||||
{
|
||||
var items = (await resolvedTarget.Items.GetItemsAsync() ?? throw new NullReferenceException()).ToList();
|
||||
var items = resolvedTarget.ItemsCollection.ToList();
|
||||
var newName = name;
|
||||
var targetNameExists = items.Any(i => i.Path.GetName() == newName);
|
||||
if (transportMode == TransportMode.Merge)
|
||||
|
||||
Reference in New Issue
Block a user