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.
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:
Frends.SFTP/Frends.SFTP.UploadFiles/Frends.SFTP.UploadFiles/Definitions/SingleFileTransfer.cs
Lines 247 to 255 in 95b5b9b
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.