Skip to content

Commit

Permalink
Merge pull request robinrodricks#295 from unreal/master
Browse files Browse the repository at this point in the history
add fix for robinrodricks#291 to SetDataTypeAsync
  • Loading branch information
robinrodricks authored May 2, 2018
2 parents f604fcd + c9556ee commit 75d895b
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions FluentFTP/Client/FtpClient_LowLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1452,26 +1452,30 @@ protected void EndSetDataType(IAsyncResult ar) {
/// </summary>
/// <param name="type">ASCII/Binary</param>
protected async Task SetDataTypeAsync(FtpDataType type) {
//TODO: Add cancellation support
FtpReply reply;
switch (type)
{
case FtpDataType.ASCII:
if (!(reply = await ExecuteAsync("TYPE A")).Success)
throw new FtpCommandException(reply);
break;
case FtpDataType.Binary:
if (!(reply = await ExecuteAsync("TYPE I")).Success)
throw new FtpCommandException(reply);
break;
default:
throw new FtpException("Unsupported data type: " + type.ToString());
}
// FIX : #291 only change the data type if different
if (CurrentDataType == type)
return

//TODO: Add cancellation support
FtpReply reply;
switch (type)
{
case FtpDataType.ASCII:
if (!(reply = await ExecuteAsync("TYPE A")).Success)
throw new FtpCommandException(reply);
break;
case FtpDataType.Binary:
if (!(reply = await ExecuteAsync("TYPE I")).Success)
throw new FtpCommandException(reply);
break;
default:
throw new FtpException("Unsupported data type: " + type.ToString());
}

CurrentDataType = type;
}
}
#endif
#endregion

}
}
}

0 comments on commit 75d895b

Please sign in to comment.