Jelajahi Sumber

Do not create extra directory level when uploading the content of a directory.
Fixes issue #128.

drieseng 9 tahun lalu
induk
melakukan
e83486c391
2 mengubah file dengan 10 tambahan dan 3 penghapusan
  1. 6 3
      src/Renci.SshNet/ScpClient.NET.cs
  2. 4 0
      src/Renci.SshNet/ScpClient.cs

+ 6 - 3
src/Renci.SshNet/ScpClient.NET.cs

@@ -63,16 +63,19 @@ namespace Renci.SshNet
                 channel.DataReceived += (sender, e) => input.Write(e.Data, 0, e.Data.Length);
                 channel.Open();
 
-                //  Send channel command request
+                // start recursive upload
                 channel.SendExecRequest(string.Format("scp -rt \"{0}\"", path));
                 CheckReturnCode(input);
 
+                // set last write and last access time on specified remote path
                 InternalSetTimestamp(channel, input, directoryInfo.LastWriteTimeUtc, directoryInfo.LastAccessTimeUtc);
-                SendData(channel, string.Format("D0755 0 {0}\n", Path.GetFileName(path)));
+                SendData(channel, string.Format("D0755 0 {0}\n", "."));
                 CheckReturnCode(input);
 
+                // recursively upload files and directories in specified remote path
                 InternalUpload(channel, input, directoryInfo);
 
+                // terminate upload of specified remote path
                 SendData(channel, "E\n");
                 CheckReturnCode(input);
             }
@@ -156,7 +159,7 @@ namespace Renci.SshNet
             var directories = directoryInfo.GetDirectories();
             foreach (var directory in directories)
             {
-                InternalSetTimestamp(channel, input, directoryInfo.LastWriteTimeUtc, directoryInfo.LastAccessTimeUtc);
+                InternalSetTimestamp(channel, input, directoryInfo.LastWriteTimeUtc, directory.LastAccessTimeUtc);
                 SendData(channel, string.Format("D0755 0 {0}\n", directory.Name));
                 CheckReturnCode(input);
 

+ 4 - 0
src/Renci.SshNet/ScpClient.cs

@@ -12,6 +12,10 @@ namespace Renci.SshNet
     /// <summary>
     /// Provides SCP client functionality.
     /// </summary>
+    /// <remarks>
+    /// More information on the SCP protocol is available here:
+    /// https://github.com/net-ssh/net-scp/blob/master/lib/net/scp.rb
+    /// </remarks>
     public partial class ScpClient : BaseClient
     {
         private static readonly Regex FileInfoRe = new Regex(@"C(?<mode>\d{4}) (?<length>\d+) (?<filename>.+)");