From bf33852a22394625818021e9b2ca7d603901f77e Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 16:50:35 +0800 Subject: [PATCH 01/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 3f0d64e..e7054ed 100644 --- a/src/session.cr +++ b/src/session.cr @@ -343,7 +343,7 @@ class SSH2::Session File.open(local_path, "w") do |f| buf = uninitialized UInt8[1024] while read_bytes < file_size - bytes_to_read = min.call(buf.length, file_size - read_bytes) + bytes_to_read = min.call(buf.size, file_size - read_bytes) len = ch.read(buf.to_slice, bytes_to_read).to_i32 f.write(buf.to_slice, len) break if len <= 0 From 82c0f5b5f281d286eed3955a0e4aaea5e1b6c79e Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 17:16:31 +0800 Subject: [PATCH 02/32] Update channel.cr --- src/channel.cr | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/channel.cr b/src/channel.cr index b1eab2a..1b00b9f 100644 --- a/src/channel.cr +++ b/src/channel.cr @@ -109,7 +109,15 @@ class SSH2::Channel < IO return 0 if eof? read(0, slice) end - + def read(slice : Slice(UInt32)) + return 0 if eof? + read(0, slice) + end + def read(slice : Slice(UInt64)) + return 0 if eof? + read(0, slice) + end + def write(slice : Slice(UInt8)) write(0, slice) end From 648f8d1405c8f7a6dca0fc82aa4b8e674e33bebc Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 17:18:41 +0800 Subject: [PATCH 03/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index e7054ed..c664883 100644 --- a/src/session.cr +++ b/src/session.cr @@ -341,7 +341,7 @@ class SSH2::Session file_size = stat.st_size read_bytes = 0 File.open(local_path, "w") do |f| - buf = uninitialized UInt8[1024] + buf = StaticArray(Int8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size bytes_to_read = min.call(buf.size, file_size - read_bytes) len = ch.read(buf.to_slice, bytes_to_read).to_i32 From 46f6c3c5d2eeaeff0193a99aa2ae162d26be7563 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 17:38:53 +0800 Subject: [PATCH 04/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index c664883..eb37a31 100644 --- a/src/session.cr +++ b/src/session.cr @@ -331,7 +331,7 @@ class SSH2::Session # Download a file from the remote host via SCP to the local filesystem. def scp_recv_file(path, local_path = path) - min = -> (x : Int32|Int64, y : Int32|Int64) { x < y ? x : y} + min = -> (x : Int32, y : Int32) { x < y ? x : y} # libssh2 scp_recv method has a bug where its channel's read method doesn't # return 0 value to indicate the end of file(EOF). The only way to find EOF From e13a387e0f3091c1edcda2d89e2a34e49b8057d6 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 17:40:44 +0800 Subject: [PATCH 05/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index eb37a31..42d68a6 100644 --- a/src/session.cr +++ b/src/session.cr @@ -331,7 +331,7 @@ class SSH2::Session # Download a file from the remote host via SCP to the local filesystem. def scp_recv_file(path, local_path = path) - min = -> (x : Int32, y : Int32) { x < y ? x : y} + min = -> (x : Int64, y : Int64) { x < y ? x : y} # libssh2 scp_recv method has a bug where its channel's read method doesn't # return 0 value to indicate the end of file(EOF). The only way to find EOF From ee95ee29d04e7e213c32c1c06f72067ae15c0349 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 17:52:21 +0800 Subject: [PATCH 06/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 42d68a6..8e7266e 100644 --- a/src/session.cr +++ b/src/session.cr @@ -343,7 +343,7 @@ class SSH2::Session File.open(local_path, "w") do |f| buf = StaticArray(Int8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size - bytes_to_read = min.call(buf.size, file_size - read_bytes) +bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) len = ch.read(buf.to_slice, bytes_to_read).to_i32 f.write(buf.to_slice, len) break if len <= 0 From 00c9f827d1a09025d04f7caeb2b068d04e9cca2a Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 17:54:17 +0800 Subject: [PATCH 07/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 8e7266e..06a3a08 100644 --- a/src/session.cr +++ b/src/session.cr @@ -331,7 +331,7 @@ class SSH2::Session # Download a file from the remote host via SCP to the local filesystem. def scp_recv_file(path, local_path = path) - min = -> (x : Int64, y : Int64) { x < y ? x : y} + min = -> (x : Int64|Int32, y : Int64|Int32) { x < y ? x : y} # libssh2 scp_recv method has a bug where its channel's read method doesn't # return 0 value to indicate the end of file(EOF). The only way to find EOF From 5bfaf07ae3d965c7a1dfcdd39b4b340f3c0050b5 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 18:01:24 +0800 Subject: [PATCH 08/32] Update session.cr --- src/session.cr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 06a3a08..e76bb21 100644 --- a/src/session.cr +++ b/src/session.cr @@ -344,7 +344,8 @@ class SSH2::Session buf = StaticArray(Int8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) - len = ch.read(buf.to_slice, bytes_to_read).to_i32 +buf2 = StaticArray(Int8, bytes_to_read).new(0) + len = ch.read(buf2.to_slice).to_i32 f.write(buf.to_slice, len) break if len <= 0 read_bytes += len From e61d3f87167fc43430449d5331a6edcec93c3cef Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 18:04:08 +0800 Subject: [PATCH 09/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index e76bb21..1e5c0d0 100644 --- a/src/session.cr +++ b/src/session.cr @@ -344,7 +344,7 @@ class SSH2::Session buf = StaticArray(Int8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) -buf2 = StaticArray(Int8, bytes_to_read).new(0) +buf2 = Array.new(Int8, bytes_to_read) len = ch.read(buf2.to_slice).to_i32 f.write(buf.to_slice, len) break if len <= 0 From 87dbf680ad3ac456ab119f9fe20e725d3966c788 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 18:05:40 +0800 Subject: [PATCH 10/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 1e5c0d0..c236280 100644 --- a/src/session.cr +++ b/src/session.cr @@ -344,7 +344,7 @@ class SSH2::Session buf = StaticArray(Int8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) -buf2 = Array.new(Int8, bytes_to_read) +buf2 = Array(Int8).new( bytes_to_read,0) len = ch.read(buf2.to_slice).to_i32 f.write(buf.to_slice, len) break if len <= 0 From bbf54afe4026f59eb7495433044c0ab47dd0a2fb Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 18:08:56 +0800 Subject: [PATCH 11/32] Update session.cr --- src/session.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/session.cr b/src/session.cr index c236280..da2cc52 100644 --- a/src/session.cr +++ b/src/session.cr @@ -344,8 +344,8 @@ class SSH2::Session buf = StaticArray(Int8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) -buf2 = Array(Int8).new( bytes_to_read,0) - len = ch.read(buf2.to_slice).to_i32 +buf2 = Slice(Int8).new( bytes_to_read,0) + len = ch.read(buf2).to_i32 f.write(buf.to_slice, len) break if len <= 0 read_bytes += len From a341e63e95321c0fccea1dedd1427d90d42f804f Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 18:19:55 +0800 Subject: [PATCH 12/32] Update session.cr --- src/session.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/session.cr b/src/session.cr index da2cc52..2b55e1b 100644 --- a/src/session.cr +++ b/src/session.cr @@ -343,9 +343,9 @@ class SSH2::Session File.open(local_path, "w") do |f| buf = StaticArray(Int8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size -bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) -buf2 = Slice(Int8).new( bytes_to_read,0) - len = ch.read(buf2).to_i32 +#bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) +#buf2 = Slice(Int8).new( bytes_to_read,0) + len = ch.read(buf.to_slice).to_i32 f.write(buf.to_slice, len) break if len <= 0 read_bytes += len From 4e0a5d1b0540c80ba8a88b8790730efb817d9a74 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 18:21:48 +0800 Subject: [PATCH 13/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 2b55e1b..e6ccae1 100644 --- a/src/session.cr +++ b/src/session.cr @@ -341,7 +341,7 @@ class SSH2::Session file_size = stat.st_size read_bytes = 0 File.open(local_path, "w") do |f| - buf = StaticArray(Int8, 1024).new(0) # => 42#uninitialized UInt8[1024] + buf = StaticArray(UInt8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size #bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) #buf2 = Slice(Int8).new( bytes_to_read,0) From 9438cfe9bf76e0ef29d7f5263a786ba9f9e31058 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 18:29:22 +0800 Subject: [PATCH 14/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index e6ccae1..fcf30c3 100644 --- a/src/session.cr +++ b/src/session.cr @@ -346,7 +346,7 @@ class SSH2::Session #bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) #buf2 = Slice(Int8).new( bytes_to_read,0) len = ch.read(buf.to_slice).to_i32 - f.write(buf.to_slice, len) + f.write buf.to_slice, len break if len <= 0 read_bytes += len end From c63453be2f7014c4bcec8b0a2c8c4d1b3d93d973 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 18:30:26 +0800 Subject: [PATCH 15/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index fcf30c3..c82d621 100644 --- a/src/session.cr +++ b/src/session.cr @@ -346,7 +346,7 @@ class SSH2::Session #bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) #buf2 = Slice(Int8).new( bytes_to_read,0) len = ch.read(buf.to_slice).to_i32 - f.write buf.to_slice, len + f.write buf.to_slice break if len <= 0 read_bytes += len end From 36aa4998eed5de4746f6c239bb48e9a97223a6fb Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 18:34:32 +0800 Subject: [PATCH 16/32] Update session.cr --- src/session.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/session.cr b/src/session.cr index c82d621..0107318 100644 --- a/src/session.cr +++ b/src/session.cr @@ -345,9 +345,9 @@ class SSH2::Session while read_bytes < file_size #bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) #buf2 = Slice(Int8).new( bytes_to_read,0) - len = ch.read(buf.to_slice).to_i32 - f.write buf.to_slice + len = ch.read(buf.to_slice).to_i32 break if len <= 0 + f.write buf.to_slice read_bytes += len end end From be89d3e33e322e89216fa347aeb9dd85583493c6 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 19:35:30 +0800 Subject: [PATCH 17/32] Update session.cr --- src/session.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/session.cr b/src/session.cr index 0107318..97ef505 100644 --- a/src/session.cr +++ b/src/session.cr @@ -343,11 +343,11 @@ class SSH2::Session File.open(local_path, "w") do |f| buf = StaticArray(UInt8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size -#bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) -#buf2 = Slice(Int8).new( bytes_to_read,0) - len = ch.read(buf.to_slice).to_i32 +bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) +buf2 = Slice(Int8).new( bytes_to_read.as(Int),0) + len = ch.read(buf2).to_i32 break if len <= 0 - f.write buf.to_slice + f.write buf2.to_slice read_bytes += len end end From 8af0c91ae4c138e859f505ac5ac34530ec9ae0db Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 19:40:09 +0800 Subject: [PATCH 18/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 97ef505..7ecc7d3 100644 --- a/src/session.cr +++ b/src/session.cr @@ -344,7 +344,7 @@ class SSH2::Session buf = StaticArray(UInt8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) -buf2 = Slice(Int8).new( bytes_to_read.as(Int),0) +buf2 = Slice(Int8).new( bytes_to_read.as(Int32)) len = ch.read(buf2).to_i32 break if len <= 0 f.write buf2.to_slice From 55d12f9add804096efecfb6e6d913c0fe81479e7 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 19:40:57 +0800 Subject: [PATCH 19/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 7ecc7d3..349dd49 100644 --- a/src/session.cr +++ b/src/session.cr @@ -344,7 +344,7 @@ class SSH2::Session buf = StaticArray(UInt8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) -buf2 = Slice(Int8).new( bytes_to_read.as(Int32)) +buf2 = Slice(UInt8).new( bytes_to_read.as(Int32)) len = ch.read(buf2).to_i32 break if len <= 0 f.write buf2.to_slice From 3b5fca3b546a9bbe3433e1eb5994864e92bcb37c Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 20:37:14 +0800 Subject: [PATCH 20/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 349dd49..d6f3235 100644 --- a/src/session.cr +++ b/src/session.cr @@ -344,7 +344,7 @@ class SSH2::Session buf = StaticArray(UInt8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) -buf2 = Slice(UInt8).new( bytes_to_read.as(Int32)) +buf2 = Slice(UInt8).new( bytes_to_read.to_int32) len = ch.read(buf2).to_i32 break if len <= 0 f.write buf2.to_slice From ad460b6fa392fa31c5499a04ef7cb18c91ad24b7 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 20:37:50 +0800 Subject: [PATCH 21/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index d6f3235..2dab540 100644 --- a/src/session.cr +++ b/src/session.cr @@ -344,7 +344,7 @@ class SSH2::Session buf = StaticArray(UInt8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) -buf2 = Slice(UInt8).new( bytes_to_read.to_int32) +buf2 = Slice(UInt8).new( bytes_to_read.to_i32) len = ch.read(buf2).to_i32 break if len <= 0 f.write buf2.to_slice From feaf94e80f9df310f16f8a9c1879ad47cc98835e Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 20:39:38 +0800 Subject: [PATCH 22/32] Update session.cr --- src/session.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/session.cr b/src/session.cr index 2dab540..84325ce 100644 --- a/src/session.cr +++ b/src/session.cr @@ -343,8 +343,8 @@ class SSH2::Session File.open(local_path, "w") do |f| buf = StaticArray(UInt8, 1024).new(0) # => 42#uninitialized UInt8[1024] while read_bytes < file_size -bytes_to_read = min.call(buf.size, file_size - read_bytes).as(Int64) -buf2 = Slice(UInt8).new( bytes_to_read.to_i32) +bytes_to_read = min.call(buf.size, file_size - read_bytes).to_i32 +buf2 = Slice(UInt8).new( bytes_to_read) len = ch.read(buf2).to_i32 break if len <= 0 f.write buf2.to_slice From 449a7df7cb4e4d85f7f982820c523bb254ef090e Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 20:46:10 +0800 Subject: [PATCH 23/32] Update session.cr --- src/session.cr | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/session.cr b/src/session.cr index 84325ce..b73f540 100644 --- a/src/session.cr +++ b/src/session.cr @@ -310,6 +310,18 @@ class SSH2::Session end end end + # Send a file from a local filesystem to the remote host via SCP. + def scp_send_file(path,localpath) + if LibC.stat(path, out stat) != 0 + raise Errno.new("Unable to get stat for '#{path}'") + end + scp_send(path, (stat.st_mode & 0x3ff).to_i32, stat.st_size.to_u64, + stat.st_mtimespec.tv_sec, stat.st_atimespec.tv_sec) do |ch| + File.open(localpath, "r") do |f| + IO.copy(f, ch) + end + end + end # Request a file from the remote host via SCP. def scp_recv(path) From 38854b9732e824b032c37f3ddb60bed6f8462905 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 20:49:42 +0800 Subject: [PATCH 24/32] Update session.cr --- src/session.cr | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/session.cr b/src/session.cr index b73f540..4dfa577 100644 --- a/src/session.cr +++ b/src/session.cr @@ -315,8 +315,7 @@ class SSH2::Session if LibC.stat(path, out stat) != 0 raise Errno.new("Unable to get stat for '#{path}'") end - scp_send(path, (stat.st_mode & 0x3ff).to_i32, stat.st_size.to_u64, - stat.st_mtimespec.tv_sec, stat.st_atimespec.tv_sec) do |ch| + scp_send(path, (stat.st_mode & 0x3ff).to_i32, stat.st_size.to_u64,stat.st_mtimespec.tv_sec, stat.st_atimespec.tv_sec) do |ch| File.open(localpath, "r") do |f| IO.copy(f, ch) end From 160c428c12f4a81ede17dce8b19e2a75ce168efe Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 21:41:56 +0800 Subject: [PATCH 25/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 4dfa577..340645d 100644 --- a/src/session.cr +++ b/src/session.cr @@ -315,7 +315,7 @@ class SSH2::Session if LibC.stat(path, out stat) != 0 raise Errno.new("Unable to get stat for '#{path}'") end - scp_send(path, (stat.st_mode & 0x3ff).to_i32, stat.st_size.to_u64,stat.st_mtimespec.tv_sec, stat.st_atimespec.tv_sec) do |ch| + scp_send(path, (stat.st_mode & 0x3ff).to_i32, stat.st_size.to_u64) do |ch| File.open(localpath, "r") do |f| IO.copy(f, ch) end From 2ce2cb62b8f404267bb3f371c272a35be5fe0b30 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 21:46:09 +0800 Subject: [PATCH 26/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 340645d..2214398 100644 --- a/src/session.cr +++ b/src/session.cr @@ -289,7 +289,7 @@ class SSH2::Session # Send a file to the remote host via SCP. # A new channel is passed to the block and closed afterwards. - def scp_send(path, mode, size, mtime = Time.now.epoch, atime = Time.now.epoch) + def scp_send(path, mode, size, mtime = Time.now.local, atime = Time.now.local) channel = scp_send(path, mode, size, mtime, atime) begin yield channel From f811a166f647433132584a491200e6f6a9f23626 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 21:49:08 +0800 Subject: [PATCH 27/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 2214398..97fe7fa 100644 --- a/src/session.cr +++ b/src/session.cr @@ -289,7 +289,7 @@ class SSH2::Session # Send a file to the remote host via SCP. # A new channel is passed to the block and closed afterwards. - def scp_send(path, mode, size, mtime = Time.now.local, atime = Time.now.local) + def scp_send(path, mode, size, mtime = Time.to_utc, atime = Time.to_utc) channel = scp_send(path, mode, size, mtime, atime) begin yield channel From ab2c47619cc09061abdbe152f36b9d8603fdf961 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 21:50:26 +0800 Subject: [PATCH 28/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 97fe7fa..d9310ae 100644 --- a/src/session.cr +++ b/src/session.cr @@ -289,7 +289,7 @@ class SSH2::Session # Send a file to the remote host via SCP. # A new channel is passed to the block and closed afterwards. - def scp_send(path, mode, size, mtime = Time.to_utc, atime = Time.to_utc) + def scp_send(path, mode, size, mtime = Time.now.to_utc, atime = Time.now.to_utc) channel = scp_send(path, mode, size, mtime, atime) begin yield channel From ceacd6d59f486a7d688155802b80149e5746b458 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 21:52:36 +0800 Subject: [PATCH 29/32] Update session.cr --- src/session.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/session.cr b/src/session.cr index d9310ae..8ff05e1 100644 --- a/src/session.cr +++ b/src/session.cr @@ -282,14 +282,14 @@ class SSH2::Session # Send a file to the remote host via SCP. def scp_send(path, mode, size, mtime, atime) handle = LibSSH2.scp_send(self, path, mode.to_i32, size.to_u64, - LibC::TimeT.new(mtime), LibC::TimeT.new(atime)) +mtime,atime) #LibC::TimeT.new(mtime), LibC::TimeT.new(atime)) check_error(LibSSH2.session_last_errno(self)) Channel.new self, handle end # Send a file to the remote host via SCP. # A new channel is passed to the block and closed afterwards. - def scp_send(path, mode, size, mtime = Time.now.to_utc, atime = Time.now.to_utc) + def scp_send(path, mode, size, mtime = Time.now, atime = Time.now) channel = scp_send(path, mode, size, mtime, atime) begin yield channel From ef5394845e6863c21aeae0d5773d65f053366d52 Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 21:53:54 +0800 Subject: [PATCH 30/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index 8ff05e1..e9b0199 100644 --- a/src/session.cr +++ b/src/session.cr @@ -289,7 +289,7 @@ mtime,atime) #LibC::TimeT.new(mtime), LibC::TimeT.new(atime)) # Send a file to the remote host via SCP. # A new channel is passed to the block and closed afterwards. - def scp_send(path, mode, size, mtime = Time.now, atime = Time.now) + def scp_send(path, mode, size, mtime = Time.now.to_utc, atime = Time.now.to_utc) channel = scp_send(path, mode, size, mtime, atime) begin yield channel From 049ac8ee888c2e24375bf0c0cb306f5252155b9f Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 22:51:09 +0800 Subject: [PATCH 31/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index e9b0199..e416cd4 100644 --- a/src/session.cr +++ b/src/session.cr @@ -289,7 +289,7 @@ mtime,atime) #LibC::TimeT.new(mtime), LibC::TimeT.new(atime)) # Send a file to the remote host via SCP. # A new channel is passed to the block and closed afterwards. - def scp_send(path, mode, size, mtime = Time.now.to_utc, atime = Time.now.to_utc) + def scp_send(path, mode, size, mtime = Time.now.to_unix, atime = Time.now.to_unix) channel = scp_send(path, mode, size, mtime, atime) begin yield channel From d0494e5407d015d538b1bf8aa5faa75f41bbd3ad Mon Sep 17 00:00:00 2001 From: whidbey Date: Mon, 9 Sep 2019 23:03:04 +0800 Subject: [PATCH 32/32] Update session.cr --- src/session.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.cr b/src/session.cr index e416cd4..78861b8 100644 --- a/src/session.cr +++ b/src/session.cr @@ -312,7 +312,7 @@ mtime,atime) #LibC::TimeT.new(mtime), LibC::TimeT.new(atime)) end # Send a file from a local filesystem to the remote host via SCP. def scp_send_file(path,localpath) - if LibC.stat(path, out stat) != 0 + if LibC.stat(localpath, out stat) != 0 raise Errno.new("Unable to get stat for '#{path}'") end scp_send(path, (stat.st_mode & 0x3ff).to_i32, stat.st_size.to_u64) do |ch|