net-sftp 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/CHANGES.txt +4 -0
- data/lib/net/sftp/session.rb +1 -1
- data/lib/net/sftp/version.rb +1 -1
- data/net-sftp.gemspec +2 -2
- data/test/common.rb +12 -0
- data/test/test_download.rb +17 -3
- metadata +2 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES.txt
CHANGED
data/lib/net/sftp/session.rb
CHANGED
@@ -898,7 +898,7 @@ module Net; module SFTP
|
|
898
898
|
@packet_length = input.read_long
|
899
899
|
end
|
900
900
|
|
901
|
-
return unless input.length >= @packet_length
|
901
|
+
return unless input.length >= @packet_length + 4
|
902
902
|
packet = Net::SFTP::Packet.new(input.read(@packet_length))
|
903
903
|
input.consume!
|
904
904
|
@packet_length = nil
|
data/lib/net/sftp/version.rb
CHANGED
data/net-sftp.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "net-sftp"
|
8
|
-
s.version = "2.1.
|
8
|
+
s.version = "2.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jamis Buck", "Delano Mandelbaum"]
|
12
12
|
s.cert_chain = ["gem-public_cert.pem"]
|
13
|
-
s.date = "2013-
|
13
|
+
s.date = "2013-05-07"
|
14
14
|
s.description = "A pure Ruby implementation of the SFTP client protocol"
|
15
15
|
s.email = "net-ssh@solutious.com"
|
16
16
|
s.extra_rdoc_files = [
|
data/test/common.rb
CHANGED
@@ -125,6 +125,18 @@ class Net::SSH::Test::Channel
|
|
125
125
|
gets_data(sftp_packet(type, *args))
|
126
126
|
end
|
127
127
|
|
128
|
+
def gets_packet_in_two(fragment_len, type, *args)
|
129
|
+
fragment_len ||= 0
|
130
|
+
whole_packet = sftp_packet(type, *args)
|
131
|
+
|
132
|
+
if 0 < fragment_len && fragment_len < whole_packet.length
|
133
|
+
gets_data(whole_packet[0, whole_packet.length - fragment_len])
|
134
|
+
gets_data(whole_packet[-fragment_len..-1])
|
135
|
+
else
|
136
|
+
gets_data(whole_packet)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
128
140
|
def sends_packet(type, *args)
|
129
141
|
sends_data(sftp_packet(type, *args))
|
130
142
|
end
|
data/test/test_download.rb
CHANGED
@@ -21,6 +21,20 @@ class DownloadTest < Net::SFTP::TestCase
|
|
21
21
|
assert_equal text, file.string
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_download_file_should_transfer_remote_to_local_in_spite_of_fragmentation
|
25
|
+
local = "/path/to/local"
|
26
|
+
remote = "/path/to/remote"
|
27
|
+
text = "this is some text\n"
|
28
|
+
|
29
|
+
expect_file_transfer(remote, text, :fragment_len => 1)
|
30
|
+
|
31
|
+
file = StringIO.new
|
32
|
+
File.stubs(:open).with(local, "wb").returns(file)
|
33
|
+
|
34
|
+
assert_scripted_command { sftp.download(remote, local) }
|
35
|
+
assert_equal text, file.string
|
36
|
+
end
|
37
|
+
|
24
38
|
def test_download_large_file_should_transfer_remote_to_local
|
25
39
|
local = "/path/to/local"
|
26
40
|
remote = "/path/to/remote"
|
@@ -130,12 +144,12 @@ class DownloadTest < Net::SFTP::TestCase
|
|
130
144
|
|
131
145
|
private
|
132
146
|
|
133
|
-
def expect_file_transfer(remote, text)
|
147
|
+
def expect_file_transfer(remote, text, opts={})
|
134
148
|
expect_sftp_session :server_version => 3 do |channel|
|
135
149
|
channel.sends_packet(FXP_OPEN, :long, 0, :string, remote, :long, 0x01, :long, 0)
|
136
150
|
channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle")
|
137
151
|
channel.sends_packet(FXP_READ, :long, 1, :string, "handle", :int64, 0, :long, 32_000)
|
138
|
-
channel.
|
152
|
+
channel.gets_packet_in_two(opts[:fragment_len], FXP_DATA, :long, 1, :string, text)
|
139
153
|
channel.sends_packet(FXP_READ, :long, 2, :string, "handle", :int64, text.bytesize, :long, 32_000)
|
140
154
|
channel.gets_packet(FXP_STATUS, :long, 2, :long, 1)
|
141
155
|
channel.sends_packet(FXP_CLOSE, :long, 3, :string, "handle")
|
@@ -160,7 +174,7 @@ class DownloadTest < Net::SFTP::TestCase
|
|
160
174
|
channel.sends_packet(FXP_CLOSE, :long, data_packet_count + 2, :string, "handle")
|
161
175
|
channel.gets_packet(FXP_STATUS, :long, data_packet_count + 2, :long, 0)
|
162
176
|
end
|
163
|
-
|
177
|
+
|
164
178
|
file = StringIO.new
|
165
179
|
File.stubs(:open).with(local, "wb").returns(file)
|
166
180
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-sftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
MVhNUThCTTJKejBYb1BhblBlMzU0K2xXd2pwa1JLYkZvdy9aYlFIY0NMQ3Ey
|
39
39
|
NCtONmI2ZwpkZ0tmTkR6d2lEcHFDQT09Ci0tLS0tRU5EIENFUlRJRklDQVRF
|
40
40
|
LS0tLS0K
|
41
|
-
date: 2013-
|
41
|
+
date: 2013-05-07 00:00:00.000000000 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: net-ssh
|
metadata.gz.sig
CHANGED
Binary file
|