Pārlūkot izejas kodu

Minor improvements.

drieseng 9 gadi atpakaļ
vecāks
revīzija
ba59196821

+ 0 - 1
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
 {

+ 0 - 1
src/Renci.SshNet/ForwardedPortStatus.cs

@@ -1,5 +1,4 @@
 using System;
-using System.Globalization;
 using System.Threading;
 
 namespace Renci.SshNet

+ 1 - 1
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;
         }

+ 9 - 11
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)