StreamCopyCommandHandler, Async rename

This commit is contained in:
2022-02-16 00:12:09 +01:00
parent 89d891918c
commit f809f0a640
41 changed files with 529 additions and 182 deletions

View File

@@ -24,7 +24,7 @@ namespace FileTime.Core.Timeline
return new Difference(
Type,
Action,
new AbsolutePath(AbsolutePath.ContentProvider, AbsolutePath.Path, virtualContentProvider)
new AbsolutePath(AbsolutePath.ContentProvider, AbsolutePath.Path, AbsolutePath.Type, virtualContentProvider)
);
}
}

View File

@@ -45,11 +45,11 @@ namespace FileTime.Core.Timeline
FullName = parent?.FullName == null ? Name : parent.FullName + Constants.SeparatorChar + Name;
}
public async Task<IContainer> Clone() => new TimeContainer(Name, await _parent!.Clone(), Provider, VirtualProvider, _pointInTime);
public async Task<IContainer> CloneAsync() => new TimeContainer(Name, await _parent!.CloneAsync(), Provider, VirtualProvider, _pointInTime);
public Task<IContainer> CreateContainer(string name) => Task.FromResult((IContainer)new TimeContainer(name, this, Provider, VirtualProvider, _pointInTime));
public Task<IContainer> CreateContainerAsync(string name) => Task.FromResult((IContainer)new TimeContainer(name, this, Provider, VirtualProvider, _pointInTime));
public Task<IElement> CreateElement(string name) => Task.FromResult((IElement)new TimeElement(name, this, Provider, VirtualProvider));
public Task<IElement> CreateElementAsync(string name) => Task.FromResult((IElement)new TimeElement(name, this, Provider, VirtualProvider));
public Task Delete(bool hardDelete = false) => Task.CompletedTask;
@@ -106,7 +106,7 @@ namespace FileTime.Core.Timeline
public IContainer? GetParent() => _parent;
public async Task<bool> IsExists(string name) => (await GetItems())?.Any(i => i.Name == name) ?? false;
public async Task<bool> IsExistsAsync(string name) => (await GetItems())?.Any(i => i.Name == name) ?? false;
public async Task RefreshAsync(CancellationToken token = default) => await Refreshed.InvokeAsync(this, AsyncEventArgs.Empty, token);
@@ -125,7 +125,7 @@ namespace FileTime.Core.Timeline
if (elementDiff.Type != DifferenceItemType.Container) throw new ArgumentException($"{elementDiff}'s {nameof(Difference.Type)} property is not {DifferenceItemType.Element}.");
return new TimeElement(elementDiff.Name, this, Provider, elementDiff.AbsolutePath.VirtualContentProvider ?? elementDiff.AbsolutePath.ContentProvider);
}
public Task<bool> CanOpen() => Task.FromResult(true);
public Task<bool> CanOpenAsync() => Task.FromResult(true);
public void Destroy() => IsDestroyed = true;
public void Unload() { }

View File

@@ -48,5 +48,9 @@ namespace FileTime.Core.Timeline
public Task<long> GetElementSize(CancellationToken token = default) => Task.FromResult(-1L);
public void Destroy() => IsDestroyed = true;
public Task<IContentReader> GetContentReaderAsync() => throw new NotSupportedException();
public Task<IContentWriter> GetContentWriterAsync() => throw new NotSupportedException();
}
}

View File

@@ -30,6 +30,7 @@ namespace FileTime.Core.Timeline
public bool SupportsDirectoryLevelSoftDelete => false;
public bool IsDestroyed => false;
public bool SupportsContentStreams => false;
public TimeProvider(PointInTime pointInTime)
{
@@ -41,14 +42,14 @@ namespace FileTime.Core.Timeline
throw new NotImplementedException();
}
public Task<IContainer> Clone() => Task.FromResult((IContainer)this);
public Task<IContainer> CloneAsync() => Task.FromResult((IContainer)this);
public Task<IContainer> CreateContainer(string name)
public Task<IContainer> CreateContainerAsync(string name)
{
throw new NotImplementedException();
}
public Task<IElement> CreateElement(string name)
public Task<IElement> CreateElementAsync(string name)
{
throw new NotImplementedException();
}
@@ -82,7 +83,7 @@ namespace FileTime.Core.Timeline
throw new NotImplementedException();
}
public Task<bool> IsExists(string name)
public Task<bool> IsExistsAsync(string name)
{
throw new NotImplementedException();
}
@@ -92,10 +93,20 @@ namespace FileTime.Core.Timeline
public Task Rename(string newName) => throw new NotSupportedException();
public void SetParent(IContainer container) { }
public Task<bool> CanOpen() => Task.FromResult(true);
public Task<bool> CanOpenAsync() => Task.FromResult(true);
public void Destroy() { }
public void Unload() { }
public Task<IContentReader> GetContentReaderAsync(IElement element)
{
throw new NotSupportedException();
}
public Task<IContentWriter> GetContentWriterAsync(IElement element)
{
throw new NotSupportedException();
}
}
}

View File

@@ -139,6 +139,10 @@ namespace FileTime.Core.Timeline
_commandExecutor.ExecuteCommandAsync(commandToRun.Command, this).Wait();
}
}
catch(Exception e)
{
_logger.LogError(e, "Error while running command: {CommandType} ({Command}).", commandToRun?.Command.GetType().Name, commandToRun?.Command.DisplayLabel);
}
finally
{
DisposeCommandThread(Thread.CurrentThread, commandToRun).Wait();
@@ -151,11 +155,11 @@ namespace FileTime.Core.Timeline
{
if (command != null)
{
_logger.LogDebug("Command finished running: {0}", command.Command.DisplayLabel);
_logger.LogDebug("Command finished running: {Command}", command.Command.DisplayLabel);
_commandsToRun[0].Remove(command);
if (_commandsToRun[0].Commands.Count == 0)
{
_logger.LogDebug("Removing empty command array. {0} batch left.", _commandsToRun.Count - 1);
_logger.LogDebug("Removing empty command array. {RemainingBatchNumber} batch left.", _commandsToRun.Count - 1);
_commandsToRun.RemoveAt(0);
}
}