From ba59196821891fc2b76b36172e23ec640f54bf5e Mon Sep 17 00:00:00 2001 From: drieseng Date: Sat, 10 Sep 2016 21:11:40 +0200 Subject: [PATCH] Minor improvements. --- src/Renci.SshNet/Common/Extensions.cs | 1 - src/Renci.SshNet/ForwardedPortStatus.cs | 1 - src/Renci.SshNet/Sftp/SftpMessage.cs | 2 +- src/Renci.SshNet/Sftp/SftpSession.cs | 20 +++++++++----------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Renci.SshNet/Common/Extensions.cs b/src/Renci.SshNet/Common/Extensions.cs index 2c127351..f7ca990e 100644 --- a/src/Renci.SshNet/Common/Extensions.cs +++ b/src/Renci.SshNet/Common/Extensions.cs @@ -9,7 +9,6 @@ using System.Text; using Renci.SshNet.Abstractions; using Renci.SshNet.Common; using Renci.SshNet.Messages; -using Renci.SshNet.Messages.Connection; namespace Renci.SshNet { diff --git a/src/Renci.SshNet/ForwardedPortStatus.cs b/src/Renci.SshNet/ForwardedPortStatus.cs index d7d68365..7fce9ee7 100644 --- a/src/Renci.SshNet/ForwardedPortStatus.cs +++ b/src/Renci.SshNet/ForwardedPortStatus.cs @@ -1,5 +1,4 @@ using System; -using System.Globalization; using System.Threading; namespace Renci.SshNet diff --git a/src/Renci.SshNet/Sftp/SftpMessage.cs b/src/Renci.SshNet/Sftp/SftpMessage.cs index 90fbd0e4..d6161497 100644 --- a/src/Renci.SshNet/Sftp/SftpMessage.cs +++ b/src/Renci.SshNet/Sftp/SftpMessage.cs @@ -110,7 +110,7 @@ namespace Renci.SshNet.Sftp throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Message type '{0}' is not supported.", messageType)); } - message.Load(data, offset, data.Length - offset); + message.Load(data, offset, count); return message; } diff --git a/src/Renci.SshNet/Sftp/SftpSession.cs b/src/Renci.SshNet/Sftp/SftpSession.cs index 0fb775c6..22704e76 100644 --- a/src/Renci.SshNet/Sftp/SftpSession.cs +++ b/src/Renci.SshNet/Sftp/SftpSession.cs @@ -1210,19 +1210,17 @@ namespace Renci.SshNet.Sftp private static SshException GetSftpException(SftpStatusResponse response) { - if (response.StatusCode == StatusCodes.Ok) + switch (response.StatusCode) { - return null; + case StatusCodes.Ok: + return null; + case StatusCodes.PermissionDenied: + return new SftpPermissionDeniedException(response.ErrorMessage); + case StatusCodes.NoSuchFile: + return new SftpPathNotFoundException(response.ErrorMessage); + default: + return new SshException(response.ErrorMessage); } - if (response.StatusCode == StatusCodes.PermissionDenied) - { - return new SftpPermissionDeniedException(response.ErrorMessage); - } - if (response.StatusCode == StatusCodes.NoSuchFile) - { - return new SftpPathNotFoundException(response.ErrorMessage); - } - return new SshException(response.ErrorMessage); } private void HandleResponse(SftpResponse response)