Smb write, delete, fixes, error handling
This commit is contained in:
@@ -60,9 +60,9 @@ namespace FileTime.Core.Command
|
||||
|
||||
var newDiffs = new List<Difference>();
|
||||
|
||||
_copyOperation = (_, to, _, _) =>
|
||||
_copyOperation = async (_, to, _, _) =>
|
||||
{
|
||||
var target = to.GetParent().ResolveAsync();
|
||||
var target = await to.GetParent().ResolveAsync();
|
||||
newDiffs.Add(new Difference(
|
||||
target is IElement
|
||||
? DifferenceItemType.Element
|
||||
@@ -70,8 +70,6 @@ namespace FileTime.Core.Command
|
||||
DifferenceActionType.Create,
|
||||
to
|
||||
));
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
_createContainer = async (IContainer target, string name) =>
|
||||
@@ -188,6 +186,7 @@ namespace FileTime.Core.Command
|
||||
for (var i = 0; targetNameExists; i++)
|
||||
{
|
||||
targetName = element.Name + (i == 0 ? "_" : $"_{i}");
|
||||
targetNameExists = await target.IsExistsAsync(targetName);
|
||||
}
|
||||
}
|
||||
else if (transportMode == Command.TransportMode.Skip && targetNameExists)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace FileTime.Core.Command
|
||||
|
||||
public async Task<CanCommandRun> CanRun(PointInTime startPoint)
|
||||
{
|
||||
var resolvedContainer = Container.ResolveAsync();
|
||||
var resolvedContainer = await Container.ResolveAsync();
|
||||
if (resolvedContainer == null) return CanCommandRun.Forceable;
|
||||
|
||||
if (resolvedContainer is not IContainer container
|
||||
|
||||
@@ -48,9 +48,9 @@ namespace FileTime.Core.Command
|
||||
return startPoint.WithDifferences(newDifferences);
|
||||
}
|
||||
|
||||
public Task<CanCommandRun> CanRun(PointInTime startPoint)
|
||||
public async Task<CanCommandRun> CanRun(PointInTime startPoint)
|
||||
{
|
||||
return Task.FromResult(Source.ResolveAsync() != null ? CanCommandRun.True : CanCommandRun.False);
|
||||
return await Source.ResolveAsync() != null ? CanCommandRun.True : CanCommandRun.False;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,10 +41,13 @@ namespace FileTime.Core.CommandHandlers
|
||||
do
|
||||
{
|
||||
dataRead = await reader.ReadBytesAsync(writer.PreferredBufferSize);
|
||||
await writer.WriteBytesAsync(dataRead);
|
||||
await writer.FlushAsync();
|
||||
if (operationProgress != null) operationProgress.Progress += dataRead.LongLength;
|
||||
await copyCommandContext.UpdateProgress();
|
||||
if (dataRead.Length > 0)
|
||||
{
|
||||
await writer.WriteBytesAsync(dataRead);
|
||||
await writer.FlushAsync();
|
||||
if (operationProgress != null) operationProgress.Progress += dataRead.LongLength;
|
||||
await copyCommandContext.UpdateProgress();
|
||||
}
|
||||
}
|
||||
while (dataRead.Length > 0);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ namespace FileTime.Core.Components
|
||||
_currentLocation = value;
|
||||
await CurrentLocationChanged.InvokeAsync(this, AsyncEventArgs.Empty);
|
||||
|
||||
var currentLocationItems = (await (await GetCurrentLocation()).GetItems())!;
|
||||
var currentLocationItems = await (await GetCurrentLocation()).GetItems();
|
||||
if (currentLocationItems == null) throw new Exception("Could not get current location items.");
|
||||
await SetCurrentSelectedItem(await GetItemByLastPath() ?? (currentLocationItems.Count > 0 ? currentLocationItems[0] : null));
|
||||
_currentLocation.Refreshed.Add(HandleCurrentLocationRefresh);
|
||||
}
|
||||
@@ -155,11 +156,11 @@ namespace FileTime.Core.Components
|
||||
var currentLocationItems = (await (await GetCurrentLocation(token)).GetItems(token))!;
|
||||
if (currentSelectedName != null)
|
||||
{
|
||||
await SetCurrentSelectedItem(currentLocationItems.FirstOrDefault(i => i.FullName == currentSelectedName) ?? currentLocationItems[0]);
|
||||
await SetCurrentSelectedItem(currentLocationItems.FirstOrDefault(i => i.FullName == currentSelectedName) ?? (currentLocationItems.Count > 0 ? currentLocationItems[0] : null), token: token);
|
||||
}
|
||||
else if (currentLocationItems.Count > 0)
|
||||
{
|
||||
await SetCurrentSelectedItem(currentLocationItems[0]);
|
||||
await SetCurrentSelectedItem(currentLocationItems[0], token: token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,12 @@ namespace FileTime.Core.Models
|
||||
|
||||
if (item is IContainer container)
|
||||
{
|
||||
var result = await container.GetByPath(string.Join(Constants.SeparatorChar, paths.Skip(1)), acceptDeepestMatch);
|
||||
IItem? result = null;
|
||||
try
|
||||
{
|
||||
result = await container.GetByPath(string.Join(Constants.SeparatorChar, paths.Skip(1)), acceptDeepestMatch);
|
||||
}
|
||||
catch { }
|
||||
return result == null && acceptDeepestMatch ? this : result;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,9 +139,14 @@ namespace FileTime.Core.Timeline
|
||||
_commandExecutor.ExecuteCommandAsync(commandToRun.Command, this).Wait();
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Error while running command: {CommandType} ({Command}).", commandToRun?.Command.GetType().Name, commandToRun?.Command.DisplayLabel);
|
||||
_logger.LogError(
|
||||
e,
|
||||
"Error while running command: {CommandType} ({Command}) {Error}.",
|
||||
commandToRun?.Command.GetType().Name,
|
||||
commandToRun?.Command.DisplayLabel,
|
||||
e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user