fixed #747: SFTP handle error when disconnected while uploading

This commit is contained in:
Jaex 2015-06-28 15:32:37 +03:00
parent 83c730b2d6
commit c112b69649

View file

@ -232,6 +232,8 @@ private bool UploadStream(Stream stream, string remotePath)
}
catch (SftpPathNotFoundException)
{
// Happens when directory not exist, create directory and retry uploading
CreateDirectory(URLHelpers.GetDirectoryPath(remotePath));
using (SftpFileStream sftpStream = client.OpenWrite(remotePath))
@ -239,6 +241,10 @@ private bool UploadStream(Stream stream, string remotePath)
return TransferData(stream, sftpStream);
}
}
catch (NullReferenceException)
{
// Happens when disconnected while uploading
}
}
return false;