Fix recursive copy not working
This commit is contained in:
@@ -11,6 +11,7 @@ public class CopyCommand : CommandBase, ITransportationCommand
|
|||||||
{
|
{
|
||||||
private readonly ITimelessContentProvider _timelessContentProvider;
|
private readonly ITimelessContentProvider _timelessContentProvider;
|
||||||
private readonly ICommandSchedulerNotifier _commandSchedulerNotifier;
|
private readonly ICommandSchedulerNotifier _commandSchedulerNotifier;
|
||||||
|
private readonly CopyStrategyFactory _copyStrategyFactory;
|
||||||
private readonly ILogger<CopyCommand> _logger;
|
private readonly ILogger<CopyCommand> _logger;
|
||||||
private readonly CancellationTokenSource _cancellationTokenSource = new();
|
private readonly CancellationTokenSource _cancellationTokenSource = new();
|
||||||
|
|
||||||
@@ -29,7 +30,8 @@ public class CopyCommand : CommandBase, ITransportationCommand
|
|||||||
|
|
||||||
internal CopyCommand(
|
internal CopyCommand(
|
||||||
ITimelessContentProvider timelessContentProvider,
|
ITimelessContentProvider timelessContentProvider,
|
||||||
ICommandSchedulerNotifier commandSchedulerNotifier,
|
ICommandSchedulerNotifier commandSchedulerNotifier,
|
||||||
|
CopyStrategyFactory copyStrategyFactory,
|
||||||
ILogger<CopyCommand> logger,
|
ILogger<CopyCommand> logger,
|
||||||
IReadOnlyCollection<FullName> sources,
|
IReadOnlyCollection<FullName> sources,
|
||||||
TransportMode mode,
|
TransportMode mode,
|
||||||
@@ -42,6 +44,7 @@ public class CopyCommand : CommandBase, ITransportationCommand
|
|||||||
|
|
||||||
_timelessContentProvider = timelessContentProvider;
|
_timelessContentProvider = timelessContentProvider;
|
||||||
_commandSchedulerNotifier = commandSchedulerNotifier;
|
_commandSchedulerNotifier = commandSchedulerNotifier;
|
||||||
|
_copyStrategyFactory = copyStrategyFactory;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_currentOperationProgress
|
_currentOperationProgress
|
||||||
.Map(p =>
|
.Map(p =>
|
||||||
@@ -105,7 +108,7 @@ public class CopyCommand : CommandBase, ITransportationCommand
|
|||||||
|
|
||||||
await CalculateProgressAsync(currentTime);
|
await CalculateProgressAsync(currentTime);
|
||||||
|
|
||||||
var copyOperation = new CopyStrategy(copy, new CopyStrategyParam(_operationProgresses, _commandSchedulerNotifier.RefreshContainer));
|
var copyOperation = _copyStrategyFactory.CreateCopyStrategy(copy, _operationProgresses, _commandSchedulerNotifier.RefreshContainer);
|
||||||
|
|
||||||
var resolvedTarget = await _timelessContentProvider.GetItemByFullNameAsync(Target, currentTime);
|
var resolvedTarget = await _timelessContentProvider.GetItemByFullNameAsync(Target, currentTime);
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,19 @@ public class CopyCommandFactory : ITransportationCommandFactory<CopyCommand>
|
|||||||
{
|
{
|
||||||
private readonly ITimelessContentProvider _timelessContentProvider;
|
private readonly ITimelessContentProvider _timelessContentProvider;
|
||||||
private readonly ICommandSchedulerNotifier _commandSchedulerNotifier;
|
private readonly ICommandSchedulerNotifier _commandSchedulerNotifier;
|
||||||
|
private readonly CopyStrategyFactory _copyStrategyFactory;
|
||||||
private readonly IServiceProvider _serviceProvider;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
|
||||||
public CopyCommandFactory(
|
public CopyCommandFactory(
|
||||||
ITimelessContentProvider timelessContentProvider,
|
ITimelessContentProvider timelessContentProvider,
|
||||||
ICommandSchedulerNotifier commandSchedulerNotifier,
|
ICommandSchedulerNotifier commandSchedulerNotifier,
|
||||||
|
CopyStrategyFactory copyStrategyFactory,
|
||||||
IServiceProvider serviceProvider)
|
IServiceProvider serviceProvider)
|
||||||
|
|
||||||
{
|
{
|
||||||
_timelessContentProvider = timelessContentProvider;
|
_timelessContentProvider = timelessContentProvider;
|
||||||
_commandSchedulerNotifier = commandSchedulerNotifier;
|
_commandSchedulerNotifier = commandSchedulerNotifier;
|
||||||
|
_copyStrategyFactory = copyStrategyFactory;
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +32,7 @@ public class CopyCommandFactory : ITransportationCommandFactory<CopyCommand>
|
|||||||
=> new(
|
=> new(
|
||||||
_timelessContentProvider,
|
_timelessContentProvider,
|
||||||
_commandSchedulerNotifier,
|
_commandSchedulerNotifier,
|
||||||
|
_copyStrategyFactory,
|
||||||
_serviceProvider.GetRequiredService<ILogger<CopyCommand>>(),
|
_serviceProvider.GetRequiredService<ILogger<CopyCommand>>(),
|
||||||
sources,
|
sources,
|
||||||
mode,
|
mode,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using FileTime.Core.ContentAccess;
|
||||||
using FileTime.Core.Models;
|
using FileTime.Core.Models;
|
||||||
using FileTime.Core.Timeline;
|
using FileTime.Core.Timeline;
|
||||||
|
|
||||||
@@ -7,11 +8,13 @@ public class CopyStrategy : ICopyStrategy
|
|||||||
{
|
{
|
||||||
private readonly CopyFunc _copy;
|
private readonly CopyFunc _copy;
|
||||||
private readonly CopyStrategyParam _copyStrategyParam;
|
private readonly CopyStrategyParam _copyStrategyParam;
|
||||||
|
private readonly IContentAccessorFactory _contentAccessorFactory;
|
||||||
|
|
||||||
public CopyStrategy(CopyFunc copy, CopyStrategyParam copyStrategyParam)
|
public CopyStrategy(CopyFunc copy, CopyStrategyParam copyStrategyParam, IContentAccessorFactory contentAccessorFactory)
|
||||||
{
|
{
|
||||||
_copy = copy;
|
_copy = copy;
|
||||||
_copyStrategyParam = copyStrategyParam;
|
_copyStrategyParam = copyStrategyParam;
|
||||||
|
_contentAccessorFactory = contentAccessorFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ContainerCopyDoneAsync(AbsolutePath containerPath)
|
public async Task ContainerCopyDoneAsync(AbsolutePath containerPath)
|
||||||
@@ -33,11 +36,14 @@ public class CopyStrategy : ICopyStrategy
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (to.Path.GetParent() is { } parent)
|
if (to.Path.GetParent() is { } parent)
|
||||||
|
{
|
||||||
await _copyStrategyParam.RefreshContainerAsync(parent);
|
await _copyStrategyParam.RefreshContainerAsync(parent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task CreateContainerAsync(IContainer target, string name, PointInTime currentTime)
|
public async Task CreateContainerAsync(IContainer target, string name, PointInTime currentTime)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var itemCreator = _contentAccessorFactory.GetItemCreator(target.Provider);
|
||||||
|
await itemCreator.CreateContainerAsync(target.Provider, target.FullName!.GetChild(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/Core/FileTime.Core.Command/Copy/CopyStrategyFactory.cs
Normal file
18
src/Core/FileTime.Core.Command/Copy/CopyStrategyFactory.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using FileTime.Core.ContentAccess;
|
||||||
|
using FileTime.Core.Models;
|
||||||
|
|
||||||
|
namespace FileTime.Core.Command.Copy;
|
||||||
|
|
||||||
|
public class CopyStrategyFactory
|
||||||
|
{
|
||||||
|
private readonly IContentAccessorFactory _contentAccessorFactory;
|
||||||
|
|
||||||
|
public CopyStrategyFactory(IContentAccessorFactory contentAccessorFactory)
|
||||||
|
{
|
||||||
|
_contentAccessorFactory = contentAccessorFactory;
|
||||||
|
}
|
||||||
|
public ICopyStrategy CreateCopyStrategy(CopyFunc copy, List<OperationProgress> operationProgresses, Func<FullName, Task> refreshContainer)
|
||||||
|
{
|
||||||
|
return new CopyStrategy(copy, new CopyStrategyParam(operationProgresses, refreshContainer), _contentAccessorFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,6 +73,7 @@ public static class Startup
|
|||||||
private static IServiceCollection AddCommandFactories(this IServiceCollection serviceCollection) =>
|
private static IServiceCollection AddCommandFactories(this IServiceCollection serviceCollection) =>
|
||||||
serviceCollection
|
serviceCollection
|
||||||
.AddSingleton<CopyCommandFactory>()
|
.AddSingleton<CopyCommandFactory>()
|
||||||
|
.AddSingleton<CopyStrategyFactory>()
|
||||||
.AddSingleton<MoveCommandFactory>();
|
.AddSingleton<MoveCommandFactory>();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
|||||||
parentFullName,
|
parentFullName,
|
||||||
AbsolutePathType.Container);
|
AbsolutePathType.Container);
|
||||||
|
|
||||||
return new Container(
|
var container = new Container(
|
||||||
name,
|
name,
|
||||||
name,
|
name,
|
||||||
fullName,
|
fullName,
|
||||||
@@ -240,6 +240,8 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
|||||||
new ExtensionCollection().AsReadOnly(),
|
new ExtensionCollection().AsReadOnly(),
|
||||||
new ObservableCollection<AbsolutePath>()
|
new ObservableCollection<AbsolutePath>()
|
||||||
);
|
);
|
||||||
|
container.StopLoading();
|
||||||
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IItem CreateEmptyElement(NativePath nativePath)
|
private IItem CreateEmptyElement(NativePath nativePath)
|
||||||
@@ -302,6 +304,10 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
|||||||
{
|
{
|
||||||
Task.Run(async () => await LoadChildren(container, directoryInfo, children, pointInTime, exceptions));
|
Task.Run(async () => await LoadChildren(container, directoryInfo, children, pointInTime, exceptions));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
container.StopLoading();
|
||||||
|
}
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user