Skip to content

Commit ba59196

Browse files
committed
Minor improvements.
1 parent 3808aae commit ba59196

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

src/Renci.SshNet/Common/Extensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Renci.SshNet.Abstractions;
1010
using Renci.SshNet.Common;
1111
using Renci.SshNet.Messages;
12-
using Renci.SshNet.Messages.Connection;
1312

1413
namespace Renci.SshNet
1514
{

src/Renci.SshNet/ForwardedPortStatus.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Globalization;
32
using System.Threading;
43

54
namespace Renci.SshNet

src/Renci.SshNet/Sftp/SftpMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private static SftpMessage Load(uint protocolVersion, SftpMessageTypes messageTy
110110
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Message type '{0}' is not supported.", messageType));
111111
}
112112

113-
message.Load(data, offset, data.Length - offset);
113+
message.Load(data, offset, count);
114114

115115
return message;
116116
}

src/Renci.SshNet/Sftp/SftpSession.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,19 +1210,17 @@ public uint CalculateOptimalWriteLength(uint bufferSize, byte[] handle)
12101210

12111211
private static SshException GetSftpException(SftpStatusResponse response)
12121212
{
1213-
if (response.StatusCode == StatusCodes.Ok)
1213+
switch (response.StatusCode)
12141214
{
1215-
return null;
1215+
case StatusCodes.Ok:
1216+
return null;
1217+
case StatusCodes.PermissionDenied:
1218+
return new SftpPermissionDeniedException(response.ErrorMessage);
1219+
case StatusCodes.NoSuchFile:
1220+
return new SftpPathNotFoundException(response.ErrorMessage);
1221+
default:
1222+
return new SshException(response.ErrorMessage);
12161223
}
1217-
if (response.StatusCode == StatusCodes.PermissionDenied)
1218-
{
1219-
return new SftpPermissionDeniedException(response.ErrorMessage);
1220-
}
1221-
if (response.StatusCode == StatusCodes.NoSuchFile)
1222-
{
1223-
return new SftpPathNotFoundException(response.ErrorMessage);
1224-
}
1225-
return new SshException(response.ErrorMessage);
12261224
}
12271225

12281226
private void HandleResponse(SftpResponse response)

0 commit comments

Comments
 (0)