Merge pull request #3225 from omkelderman/ftp-fix

add call to GetReply after using OpenRead or OpenWrite according to FluentFTP documentation
This commit is contained in:
Jaex 2018-03-24 03:46:25 +03:00 committed by GitHub
commit 45a9975432
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -231,10 +231,7 @@ public bool UploadData(Stream localStream, string remotePath)
{
try
{
using (Stream remoteStream = client.OpenWrite(remotePath))
{
return TransferData(localStream, remoteStream);
}
return UploadData2(localStream, remotePath);
}
catch (FtpCommandException e)
{
@ -243,10 +240,7 @@ public bool UploadData(Stream localStream, string remotePath)
{
CreateMultiDirectory(URLHelpers.GetDirectoryPath(remotePath));
using (Stream remoteStream = client.OpenWrite(remotePath))
{
return TransferData(localStream, remoteStream);
}
return UploadData2(localStream, remotePath);
}
throw e;
@ -256,6 +250,17 @@ public bool UploadData(Stream localStream, string remotePath)
return false;
}
private bool UploadData2(Stream localStream, string remotePath)
{
bool result;
using (Stream remoteStream = client.OpenWrite(remotePath))
{
result = TransferData(localStream, remoteStream);
}
FtpReply ftpReply = client.GetReply();
return result && ftpReply.Success;
}
public void UploadData(byte[] data, string remotePath)
{
using (MemoryStream stream = new MemoryStream(data, false))
@ -322,6 +327,7 @@ public void DownloadFile(string remotePath, Stream localStream)
{
TransferData(remoteStream, localStream);
}
client.GetReply();
}
}