Skip to content

SFTP.UploadFiles - Bug in Assume file existence #207

@RikuVirtanen

Description

@RikuVirtanen

When the Assume file existence option is true, the Task will assume that there is a destination file to be overwritten. The Task will end up in an exception if no destination file needs to be overwritten. This is because the Task doesn't check that the file exists:

if (removeExisting)
{
SetCurrentState(
TransferState.DeleteDestinationFile,
$"Deleting destination file {Path.GetFileName(DestinationFileWithMacrosExpanded)} that is to be overwritten");
await client.DeleteFileAsync(DestinationFileWithMacrosExpanded, cancellationToken);
_logger.NotifyInformation(BatchContext, $"FILE DELETE: Destination file {Path.GetFileName(DestinationFileWithMacrosExpanded)} deleted.");
}

In the case of Assume file existence the client.DeleteFileAsync() method should be surrounded with try - catch and the error should be caught so that those situations can be handled. client.Exists() method will do a lstat to the server, which is precisely what the Assume file existence option was made to skip, so we can't add that there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions