net-sftp 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/{CHANGELOG.rdoc → CHANGES.txt} +10 -0
- data/LICENSE.txt +19 -0
- data/README.rdoc +20 -1
- data/Rakefile +45 -21
- data/gem-public_cert.pem +20 -0
- data/lib/net/sftp/operations/download.rb +1 -1
- data/lib/net/sftp/operations/file.rb +0 -1
- data/lib/net/sftp/operations/upload.rb +13 -5
- data/lib/net/sftp/session.rb +2 -2
- data/lib/net/sftp/version.rb +2 -2
- data/net-sftp.gemspec +91 -19
- data/test/common.rb +1 -1
- data/test/test_all.rb +1 -1
- data/test/test_download.rb +34 -13
- data/test/test_upload.rb +17 -3
- metadata +113 -101
- metadata.gz.sig +3 -0
data.tar.gz.sig
ADDED
Binary file
|
@@ -1,4 +1,14 @@
|
|
1
1
|
|
2
|
+
=== 2.1.0 / 06 Feb 2013
|
3
|
+
|
4
|
+
* Added public cert. All gem releases are now signed. See INSTALL in readme.
|
5
|
+
* Remove self-require, it causes a warning in Ruby 1.9.2. [jbarnette]
|
6
|
+
* Allow for upload to use the filename of the local file by default [czarneckid]
|
7
|
+
* Properly handle receiving less data than requested. [thedarkone]
|
8
|
+
* Added option to create directory on directory upload [Pablo Merino]
|
9
|
+
* Remove a warnings in tests [kachick]
|
10
|
+
|
11
|
+
|
2
12
|
=== 2.0.5 / 19 Aug 2010
|
3
13
|
|
4
14
|
* Fixed missing StringIO exception in download! [Toby Bryans, Delano Mandelbaum]
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright © 2008 Jamis Buck
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the ‘Software’), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
= Net::SFTP
|
2
2
|
|
3
|
-
* http://net-ssh.
|
3
|
+
* Docs: http://net-ssh.github.com/net-sftp
|
4
|
+
* Issues: https://github.com/net-ssh/net-sftp/issues
|
5
|
+
* Codes: https://github.com/net-ssh/net-sftp
|
6
|
+
* Email: net-ssh@solutious.com
|
7
|
+
|
8
|
+
<em>As of v2.1.0, all gem releases are signed. See INSTALL.</em>
|
9
|
+
|
4
10
|
|
5
11
|
== DESCRIPTION:
|
6
12
|
|
@@ -63,6 +69,19 @@ If you wish to run the tests, you'll need:
|
|
63
69
|
|
64
70
|
* gem install net-sftp (might need sudo privileges)
|
65
71
|
|
72
|
+
However, in order to be sure the code you're installing hasn't been tampered with, it's recommended that you verify the signiture[http://docs.rubygems.org/read/chapter/21]. To do this, you need to add my public key as a trusted certificate (you only need to do this once):
|
73
|
+
|
74
|
+
# Add the public key as a trusted certificate
|
75
|
+
# (You only need to do this once)
|
76
|
+
$ curl -O https://raw.github.com/net-ssh/net-ssh/master/gem-public_cert.pem
|
77
|
+
$ gem cert --add gem-public_cert.pem
|
78
|
+
|
79
|
+
Then, when install the gem, do so with high security:
|
80
|
+
|
81
|
+
$ gem install net-ssh -P HighSecurity
|
82
|
+
|
83
|
+
If you don't add the public key, you'll see an error like "Couldn't verify data signature". If you're still having trouble let me know and I'll give you a hand.
|
84
|
+
|
66
85
|
Or, if you prefer to do it the hard way (sans Rubygems):
|
67
86
|
|
68
87
|
* tar xzf net-ssh-*.tgz
|
data/Rakefile
CHANGED
@@ -1,30 +1,54 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
require "rubygems"
|
2
|
+
require "rake"
|
3
|
+
require "rake/clean"
|
4
|
+
require "rdoc/task"
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
abort "You'll need to have `echoe' installed to use Net::SFTP's Rakefile"
|
8
|
-
end
|
6
|
+
task :default => ["build"]
|
7
|
+
CLEAN.include [ 'pkg', 'rdoc' ]
|
8
|
+
name = "net-sftp"
|
9
9
|
|
10
|
+
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
11
|
+
require "net/sftp/version"
|
10
12
|
version = Net::SFTP::Version::STRING.dup
|
11
|
-
if ENV['SNAPSHOT'].to_i == 1
|
12
|
-
version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
|
13
|
-
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
begin
|
15
|
+
require "jeweler"
|
16
|
+
Jeweler::Tasks.new do |s|
|
17
|
+
s.version = version
|
18
|
+
s.name = name
|
19
|
+
s.rubyforge_project = s.name
|
20
|
+
s.summary = "A pure Ruby implementation of the SFTP client protocol"
|
21
|
+
s.description = s.summary
|
22
|
+
s.email = "net-ssh@solutious.com"
|
23
|
+
s.homepage = "https://github.com/net-ssh/net-sftp"
|
24
|
+
s.authors = ["Jamis Buck", "Delano Mandelbaum"]
|
18
25
|
|
19
|
-
|
20
|
-
p.email = "netsftp@solutious.com"
|
21
|
-
p.summary = "A pure Ruby implementation of the SFTP client protocol"
|
22
|
-
p.url = "http://net-ssh.rubyforge.org/sftp"
|
26
|
+
s.add_dependency 'net-ssh', ">=2.6.4"
|
23
27
|
|
24
|
-
|
28
|
+
s.add_development_dependency 'test-unit'
|
29
|
+
s.add_development_dependency 'mocha'
|
25
30
|
|
26
|
-
|
27
|
-
p.include_rakefile = true
|
31
|
+
s.license = "MIT"
|
28
32
|
|
29
|
-
|
33
|
+
s.signing_key = File.join('/mnt/gem/', 'gem-private_key.pem')
|
34
|
+
s.cert_chain = ['gem-public_cert.pem']
|
35
|
+
end
|
36
|
+
Jeweler::GemcutterTasks.new
|
37
|
+
rescue LoadError
|
38
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
39
|
+
end
|
40
|
+
|
41
|
+
extra_files = %w[LICENSE.txt THANKS.txt CHANGES.txt ]
|
42
|
+
RDoc::Task.new do |rdoc|
|
43
|
+
rdoc.rdoc_dir = "rdoc"
|
44
|
+
rdoc.title = "#{name} #{version}"
|
45
|
+
rdoc.generator = 'hanna' # gem install hanna-nouveau
|
46
|
+
rdoc.main = 'README.rdoc'
|
47
|
+
rdoc.rdoc_files.include("README*")
|
48
|
+
rdoc.rdoc_files.include("bin/*.rb")
|
49
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
50
|
+
extra_files.each { |file|
|
51
|
+
rdoc.rdoc_files.include(file) if File.exists?(file)
|
52
|
+
}
|
30
53
|
end
|
54
|
+
|
data/gem-public_cert.pem
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMQ8wDQYDVQQDDAZkZWxh
|
3
|
+
bm8xGTAXBgoJkiaJk/IsZAEZFglzb2x1dGlvdXMxEzARBgoJkiaJk/IsZAEZFgNj
|
4
|
+
b20wHhcNMTMwMjA2MTE1NzQ1WhcNMTQwMjA2MTE1NzQ1WjBBMQ8wDQYDVQQDDAZk
|
5
|
+
ZWxhbm8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 -318,7 +318,6 @@ module Net; module SFTP; module Operations
|
|
318
318
|
request = sftp.read(entry.handle, entry.offset, read_size, &method(:on_read))
|
319
319
|
request[:entry] = entry
|
320
320
|
request[:offset] = entry.offset
|
321
|
-
entry.offset += read_size
|
322
321
|
end
|
323
322
|
|
324
323
|
# Called when a read from a file finishes. If the read was successful
|
@@ -335,6 +334,7 @@ module Net; module SFTP; module Operations
|
|
335
334
|
elsif !response.ok?
|
336
335
|
raise "read #{entry.remote}: #{response}"
|
337
336
|
else
|
337
|
+
entry.offset += response[:data].bytesize
|
338
338
|
update_progress(:get, entry, response.request[:offset], response[:data])
|
339
339
|
entry.sink.write(response[:data])
|
340
340
|
download_next_chunk(entry)
|
@@ -30,6 +30,9 @@ module Net; module SFTP; module Operations
|
|
30
30
|
# This will upload "/path/to/directory", it's contents, it's subdirectories,
|
31
31
|
# and their contents, recursively, to "/path/to/remote" on the remote server.
|
32
32
|
#
|
33
|
+
# For uploading a directory without creating it, do
|
34
|
+
# sftp.upload!("/path/to/directory", "/path/to/remote", :mkdir => false)
|
35
|
+
#
|
33
36
|
# If you want to send data to a file on the remote server, but the data is
|
34
37
|
# in memory, you can pass an IO object and upload it's contents:
|
35
38
|
#
|
@@ -157,12 +160,17 @@ module Net; module SFTP; module Operations
|
|
157
160
|
@remote_cwd = remote
|
158
161
|
|
159
162
|
@active += 1
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
163
|
+
if @options[:mkdir]
|
164
|
+
sftp.mkdir(remote) do |response|
|
165
|
+
@active -= 1
|
166
|
+
raise StatusException.new(response, "mkdir `#{remote}'") unless response.ok?
|
167
|
+
(options[:requests] || RECURSIVE_READERS).to_i.times do
|
168
|
+
break unless process_next_entry
|
169
|
+
end
|
165
170
|
end
|
171
|
+
else
|
172
|
+
@active -= 1
|
173
|
+
process_next_entry
|
166
174
|
end
|
167
175
|
else
|
168
176
|
raise ArgumentError, "expected a file to upload" unless local.respond_to?(:read) || ::File.exists?(local)
|
data/lib/net/sftp/session.rb
CHANGED
@@ -94,12 +94,12 @@ module Net; module SFTP
|
|
94
94
|
#
|
95
95
|
# uploader = sftp.upload("/local/path", "/remote/path")
|
96
96
|
# uploader.wait
|
97
|
-
def upload(local, remote, options={}, &block)
|
97
|
+
def upload(local, remote = File.basename(local), options={}, &block)
|
98
98
|
Operations::Upload.new(self, local, remote, options, &block)
|
99
99
|
end
|
100
100
|
|
101
101
|
# Identical to #upload, but blocks until the upload is complete.
|
102
|
-
def upload!(local, remote, options={}, &block)
|
102
|
+
def upload!(local, remote = File.basename(local), options={}, &block)
|
103
103
|
upload(local, remote, options, &block).wait
|
104
104
|
end
|
105
105
|
|
data/lib/net/sftp/version.rb
CHANGED
@@ -5,8 +5,8 @@ module Net; module SFTP
|
|
5
5
|
# Describes the current version of the Net::SFTP library.
|
6
6
|
class Version < Net::SSH::Version
|
7
7
|
MAJOR = 2
|
8
|
-
MINOR =
|
9
|
-
TINY =
|
8
|
+
MINOR = 1
|
9
|
+
TINY = 0
|
10
10
|
|
11
11
|
# The current version, as a Version instance
|
12
12
|
CURRENT = new(MAJOR, MINOR, TINY)
|
data/net-sftp.gemspec
CHANGED
@@ -1,34 +1,106 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version = "2.0
|
7
|
+
s.name = "net-sftp"
|
8
|
+
s.version = "2.1.0"
|
6
9
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">=
|
8
|
-
s.authors = ["Jamis Buck"]
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
|
15
|
-
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jamis Buck", "Delano Mandelbaum"]
|
12
|
+
s.cert_chain = ["gem-public_cert.pem"]
|
13
|
+
s.date = "2013-02-06"
|
14
|
+
s.description = "A pure Ruby implementation of the SFTP client protocol"
|
15
|
+
s.email = "net-ssh@solutious.com"
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"CHANGES.txt",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"Manifest",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"gem-public_cert.pem",
|
27
|
+
"lib/net/sftp.rb",
|
28
|
+
"lib/net/sftp/constants.rb",
|
29
|
+
"lib/net/sftp/errors.rb",
|
30
|
+
"lib/net/sftp/operations/dir.rb",
|
31
|
+
"lib/net/sftp/operations/download.rb",
|
32
|
+
"lib/net/sftp/operations/file.rb",
|
33
|
+
"lib/net/sftp/operations/file_factory.rb",
|
34
|
+
"lib/net/sftp/operations/upload.rb",
|
35
|
+
"lib/net/sftp/packet.rb",
|
36
|
+
"lib/net/sftp/protocol.rb",
|
37
|
+
"lib/net/sftp/protocol/01/attributes.rb",
|
38
|
+
"lib/net/sftp/protocol/01/base.rb",
|
39
|
+
"lib/net/sftp/protocol/01/name.rb",
|
40
|
+
"lib/net/sftp/protocol/02/base.rb",
|
41
|
+
"lib/net/sftp/protocol/03/base.rb",
|
42
|
+
"lib/net/sftp/protocol/04/attributes.rb",
|
43
|
+
"lib/net/sftp/protocol/04/base.rb",
|
44
|
+
"lib/net/sftp/protocol/04/name.rb",
|
45
|
+
"lib/net/sftp/protocol/05/base.rb",
|
46
|
+
"lib/net/sftp/protocol/06/attributes.rb",
|
47
|
+
"lib/net/sftp/protocol/06/base.rb",
|
48
|
+
"lib/net/sftp/protocol/base.rb",
|
49
|
+
"lib/net/sftp/request.rb",
|
50
|
+
"lib/net/sftp/response.rb",
|
51
|
+
"lib/net/sftp/session.rb",
|
52
|
+
"lib/net/sftp/version.rb",
|
53
|
+
"net-sftp.gemspec",
|
54
|
+
"setup.rb",
|
55
|
+
"test/common.rb",
|
56
|
+
"test/protocol/01/test_attributes.rb",
|
57
|
+
"test/protocol/01/test_base.rb",
|
58
|
+
"test/protocol/01/test_name.rb",
|
59
|
+
"test/protocol/02/test_base.rb",
|
60
|
+
"test/protocol/03/test_base.rb",
|
61
|
+
"test/protocol/04/test_attributes.rb",
|
62
|
+
"test/protocol/04/test_base.rb",
|
63
|
+
"test/protocol/04/test_name.rb",
|
64
|
+
"test/protocol/05/test_base.rb",
|
65
|
+
"test/protocol/06/test_attributes.rb",
|
66
|
+
"test/protocol/06/test_base.rb",
|
67
|
+
"test/protocol/test_base.rb",
|
68
|
+
"test/test_all.rb",
|
69
|
+
"test/test_dir.rb",
|
70
|
+
"test/test_download.rb",
|
71
|
+
"test/test_file.rb",
|
72
|
+
"test/test_file_factory.rb",
|
73
|
+
"test/test_packet.rb",
|
74
|
+
"test/test_protocol.rb",
|
75
|
+
"test/test_request.rb",
|
76
|
+
"test/test_response.rb",
|
77
|
+
"test/test_session.rb",
|
78
|
+
"test/test_upload.rb"
|
79
|
+
]
|
80
|
+
s.homepage = "https://github.com/net-ssh/net-sftp"
|
81
|
+
s.licenses = ["MIT"]
|
16
82
|
s.require_paths = ["lib"]
|
17
|
-
s.rubyforge_project =
|
18
|
-
s.rubygems_version =
|
19
|
-
s.
|
20
|
-
s.
|
83
|
+
s.rubyforge_project = "net-sftp"
|
84
|
+
s.rubygems_version = "1.8.25"
|
85
|
+
s.signing_key = "/mnt/gem/gem-private_key.pem"
|
86
|
+
s.summary = "A pure Ruby implementation of the SFTP client protocol"
|
21
87
|
|
22
88
|
if s.respond_to? :specification_version then
|
23
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
89
|
s.specification_version = 3
|
25
90
|
|
26
91
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
27
|
-
s.add_runtime_dependency(%q<net-ssh>, [">= 2.
|
92
|
+
s.add_runtime_dependency(%q<net-ssh>, [">= 2.6.4"])
|
93
|
+
s.add_development_dependency(%q<test-unit>, [">= 0"])
|
94
|
+
s.add_development_dependency(%q<mocha>, [">= 0"])
|
28
95
|
else
|
29
|
-
s.add_dependency(%q<net-ssh>, [">= 2.
|
96
|
+
s.add_dependency(%q<net-ssh>, [">= 2.6.4"])
|
97
|
+
s.add_dependency(%q<test-unit>, [">= 0"])
|
98
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
30
99
|
end
|
31
100
|
else
|
32
|
-
s.add_dependency(%q<net-ssh>, [">= 2.
|
101
|
+
s.add_dependency(%q<net-ssh>, [">= 2.6.4"])
|
102
|
+
s.add_dependency(%q<test-unit>, [">= 0"])
|
103
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
33
104
|
end
|
34
105
|
end
|
106
|
+
|
data/test/common.rb
CHANGED
data/test/test_all.rb
CHANGED
data/test/test_download.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "common"
|
2
2
|
|
3
3
|
class DownloadTest < Net::SFTP::TestCase
|
4
|
+
FXP_DATA_CHUNK_SIZE = 1024
|
5
|
+
|
4
6
|
def setup
|
5
7
|
prepare_progress!
|
6
8
|
end
|
@@ -30,6 +32,19 @@ class DownloadTest < Net::SFTP::TestCase
|
|
30
32
|
assert_equal text, file.string
|
31
33
|
end
|
32
34
|
|
35
|
+
def test_download_large_file_should_handle_too_large_read_size
|
36
|
+
local = "/path/to/local"
|
37
|
+
remote = "/path/to/remote"
|
38
|
+
text = "0123456789" * 1024
|
39
|
+
|
40
|
+
# some servers put upper bound on the max read_size value and send less data than requested
|
41
|
+
too_large_read_size = FXP_DATA_CHUNK_SIZE + 1
|
42
|
+
file = prepare_large_file_download(local, remote, text, too_large_read_size)
|
43
|
+
|
44
|
+
assert_scripted_command { sftp.download(remote, local, :read_size => too_large_read_size) }
|
45
|
+
assert_equal text, file.string
|
46
|
+
end
|
47
|
+
|
33
48
|
def test_download_large_file_with_progress_should_report_progress
|
34
49
|
local = "/path/to/local"
|
35
50
|
remote = "/path/to/remote"
|
@@ -121,25 +136,29 @@ class DownloadTest < Net::SFTP::TestCase
|
|
121
136
|
channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle")
|
122
137
|
channel.sends_packet(FXP_READ, :long, 1, :string, "handle", :int64, 0, :long, 32_000)
|
123
138
|
channel.gets_packet(FXP_DATA, :long, 1, :string, text)
|
124
|
-
channel.sends_packet(FXP_READ, :long, 2, :string, "handle", :int64,
|
139
|
+
channel.sends_packet(FXP_READ, :long, 2, :string, "handle", :int64, text.bytesize, :long, 32_000)
|
125
140
|
channel.gets_packet(FXP_STATUS, :long, 2, :long, 1)
|
126
141
|
channel.sends_packet(FXP_CLOSE, :long, 3, :string, "handle")
|
127
142
|
channel.gets_packet(FXP_STATUS, :long, 3, :long, 0)
|
128
143
|
end
|
129
144
|
end
|
130
145
|
|
131
|
-
def prepare_large_file_download(local, remote, text)
|
146
|
+
def prepare_large_file_download(local, remote, text, requested_chunk_size = FXP_DATA_CHUNK_SIZE)
|
132
147
|
expect_sftp_session :server_version => 3 do |channel|
|
133
148
|
channel.sends_packet(FXP_OPEN, :long, 0, :string, remote, :long, 0x01, :long, 0)
|
134
149
|
channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle")
|
135
|
-
|
136
|
-
|
137
|
-
|
150
|
+
offset = 0
|
151
|
+
data_packet_count = (text.bytesize / FXP_DATA_CHUNK_SIZE.to_f).ceil
|
152
|
+
data_packet_count.times do |n|
|
153
|
+
payload = text[n*FXP_DATA_CHUNK_SIZE,FXP_DATA_CHUNK_SIZE]
|
154
|
+
channel.sends_packet(FXP_READ, :long, n+1, :string, "handle", :int64, offset, :long, requested_chunk_size)
|
155
|
+
offset += payload.bytesize
|
156
|
+
channel.gets_packet(FXP_DATA, :long, n+1, :string, payload)
|
138
157
|
end
|
139
|
-
channel.sends_packet(FXP_READ, :long,
|
140
|
-
channel.gets_packet(FXP_STATUS, :long,
|
141
|
-
channel.sends_packet(FXP_CLOSE, :long,
|
142
|
-
channel.gets_packet(FXP_STATUS, :long,
|
158
|
+
channel.sends_packet(FXP_READ, :long, data_packet_count + 1, :string, "handle", :int64, offset, :long, requested_chunk_size)
|
159
|
+
channel.gets_packet(FXP_STATUS, :long, data_packet_count + 1, :long, 1)
|
160
|
+
channel.sends_packet(FXP_CLOSE, :long, data_packet_count + 2, :string, "handle")
|
161
|
+
channel.gets_packet(FXP_STATUS, :long, data_packet_count + 2, :long, 0)
|
143
162
|
end
|
144
163
|
|
145
164
|
file = StringIO.new
|
@@ -182,6 +201,8 @@ class DownloadTest < Net::SFTP::TestCase
|
|
182
201
|
# <- 15:STATUS(0)
|
183
202
|
|
184
203
|
def prepare_directory_tree_download(local, remote)
|
204
|
+
file1_contents = "contents of file1"
|
205
|
+
file2_contents = "contents of file2"
|
185
206
|
expect_sftp_session :server_version => 3 do |channel|
|
186
207
|
channel.sends_packet(FXP_OPENDIR, :long, 0, :string, remote)
|
187
208
|
channel.gets_packet(FXP_HANDLE, :long, 0, :string, "dir1")
|
@@ -214,8 +235,8 @@ class DownloadTest < Net::SFTP::TestCase
|
|
214
235
|
channel.sends_packet(FXP_OPEN, :long, 8, :string, File.join(remote, "subdir1", "file2"), :long, 0x01, :long, 0)
|
215
236
|
channel.sends_packet(FXP_READDIR, :long, 9, :string, "dir2")
|
216
237
|
|
217
|
-
channel.gets_packet(FXP_DATA, :long, 6, :string,
|
218
|
-
channel.sends_packet(FXP_READ, :long, 10, :string, "file1", :int64,
|
238
|
+
channel.gets_packet(FXP_DATA, :long, 6, :string, file1_contents)
|
239
|
+
channel.sends_packet(FXP_READ, :long, 10, :string, "file1", :int64, file1_contents.bytesize, :long, 32_000)
|
219
240
|
|
220
241
|
channel.gets_packet(FXP_STATUS, :long, 7, :long, 0)
|
221
242
|
channel.gets_packet(FXP_HANDLE, :long, 8, :string, "file2")
|
@@ -227,8 +248,8 @@ class DownloadTest < Net::SFTP::TestCase
|
|
227
248
|
channel.gets_packet(FXP_STATUS, :long, 10, :long, 1)
|
228
249
|
channel.sends_packet(FXP_CLOSE, :long, 13, :string, "file1")
|
229
250
|
|
230
|
-
channel.gets_packet(FXP_DATA, :long, 11, :string,
|
231
|
-
channel.sends_packet(FXP_READ, :long, 14, :string, "file2", :int64,
|
251
|
+
channel.gets_packet(FXP_DATA, :long, 11, :string, file2_contents)
|
252
|
+
channel.sends_packet(FXP_READ, :long, 14, :string, "file2", :int64, file2_contents.bytesize, :long, 32_000)
|
232
253
|
|
233
254
|
channel.gets_packet(FXP_STATUS, :long, 12, :long, 0)
|
234
255
|
channel.gets_packet(FXP_STATUS, :long, 13, :long, 0)
|
data/test/test_upload.rb
CHANGED
@@ -10,6 +10,20 @@ class UploadTest < Net::SFTP::TestCase
|
|
10
10
|
assert_scripted_command { sftp.upload("/path/to/local", "/path/to/remote") }
|
11
11
|
end
|
12
12
|
|
13
|
+
def test_upload_file_without_remote_uses_filename_of_local_file
|
14
|
+
expect_file_transfer("/path/to/local", "local", "here are the contents")
|
15
|
+
|
16
|
+
assert_scripted_command do
|
17
|
+
sftp.upload("/path/to/local") { |*args| record_progress(args) }
|
18
|
+
end
|
19
|
+
|
20
|
+
assert_progress_reported_open(:remote => "local")
|
21
|
+
assert_progress_reported_put(0, "here are the contents", :remote => "local")
|
22
|
+
assert_progress_reported_close(:remote => "local")
|
23
|
+
assert_progress_reported_finish
|
24
|
+
assert_no_more_reported_events
|
25
|
+
end
|
26
|
+
|
13
27
|
def test_upload_file_with_progress_should_report_progress
|
14
28
|
expect_file_transfer("/path/to/local", "/path/to/remote", "here are the contents")
|
15
29
|
|
@@ -96,7 +110,7 @@ class UploadTest < Net::SFTP::TestCase
|
|
96
110
|
prepare_directory
|
97
111
|
|
98
112
|
assert_scripted_command do
|
99
|
-
sftp.upload("/path/to/local", "/path/to/remote")
|
113
|
+
sftp.upload("/path/to/local", "/path/to/remote", :mkdir => true)
|
100
114
|
end
|
101
115
|
end
|
102
116
|
|
@@ -104,7 +118,7 @@ class UploadTest < Net::SFTP::TestCase
|
|
104
118
|
prepare_directory
|
105
119
|
|
106
120
|
assert_scripted_command do
|
107
|
-
sftp.upload("/path/to/local", "/path/to/remote") { |*args| record_progress(args) }
|
121
|
+
sftp.upload("/path/to/local", "/path/to/remote", :mkdir => true) { |*args| record_progress(args) }
|
108
122
|
end
|
109
123
|
|
110
124
|
assert_progress_reported_open(:remote => "/path/to/remote/file1")
|
@@ -216,4 +230,4 @@ class UploadTest < Net::SFTP::TestCase
|
|
216
230
|
|
217
231
|
expect_file(local, data)
|
218
232
|
end
|
219
|
-
end
|
233
|
+
end
|
metadata
CHANGED
@@ -1,76 +1,108 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-sftp
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
- 5
|
10
|
-
version: 2.0.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.1.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jamis Buck
|
9
|
+
- Delano Mandelbaum
|
14
10
|
autorequire:
|
15
11
|
bindir: bin
|
16
|
-
cert_chain:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
cert_chain:
|
13
|
+
- !binary |-
|
14
|
+
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUROakNDQWg2Z0F3SUJB
|
15
|
+
Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREJCTVE4d0RRWURWUVFEREFaa1pX
|
16
|
+
eGgKYm04eEdUQVhCZ29Ka2lhSmsvSXNaQUVaRmdsemIyeDFkR2x2ZFhNe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vVDJoUzVmOUcweTFaNzBUbHdoK1ZHRXh5Znh6VkU5WHdDK2lQcEp4
|
33
|
+
TnJhaUhZZ0YvOS9va3k3WloKUjlxMC90Sm5ldWhBZW5aZGlRa1g3b2k0TzN2
|
34
|
+
OXdSUzZZSG9XQnhNUEZLVlJMTlR6dlZKc2JtZnBDQWxwNS81ZwpwczR3UUZ5
|
35
|
+
NW1pYkVsR1ZsT29iZi9naHFaMjVIUzlKNmtkMC9DL3J5MEFVdFRvZ3NMN1R4
|
36
|
+
R3dUNGtiQ3g2M3ViCjN2eXdFRWhzSlV6ZmQ5N0dDQUJtdFFmUlRsZFgvajdG
|
37
|
+
MXovNXdkOHAraGZkb3gxaWliZHM5WnRmYVpBM0t6S24Ka2NoV045QjZ6Zzly
|
38
|
+
MVhNUThCTTJKejBYb1BhblBlMzU0K2xXd2pwa1JLYkZvdy9aYlFIY0NMQ3Ey
|
39
|
+
NCtONmI2ZwpkZ0tmTkR6d2lEcHFDQT09Ci0tLS0tRU5EIENFUlRJRklDQVRF
|
40
|
+
LS0tLS0K
|
41
|
+
date: 2013-02-06 00:00:00.000000000 Z
|
42
|
+
dependencies:
|
43
|
+
- !ruby/object:Gem::Dependency
|
22
44
|
name: net-ssh
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
25
46
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
- 9
|
34
|
-
version: 2.0.9
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.6.4
|
35
51
|
type: :runtime
|
36
|
-
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 2.6.4
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: test-unit
|
61
|
+
requirement: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: mocha
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
37
91
|
description: A pure Ruby implementation of the SFTP client protocol
|
38
|
-
email:
|
92
|
+
email: net-ssh@solutious.com
|
39
93
|
executables: []
|
40
|
-
|
41
94
|
extensions: []
|
42
|
-
|
43
|
-
|
44
|
-
-
|
45
|
-
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
- lib/net/sftp/operations/file.rb
|
50
|
-
- lib/net/sftp/operations/file_factory.rb
|
51
|
-
- lib/net/sftp/operations/upload.rb
|
52
|
-
- lib/net/sftp/packet.rb
|
53
|
-
- lib/net/sftp/protocol/01/attributes.rb
|
54
|
-
- lib/net/sftp/protocol/01/base.rb
|
55
|
-
- lib/net/sftp/protocol/01/name.rb
|
56
|
-
- lib/net/sftp/protocol/02/base.rb
|
57
|
-
- lib/net/sftp/protocol/03/base.rb
|
58
|
-
- lib/net/sftp/protocol/04/attributes.rb
|
59
|
-
- lib/net/sftp/protocol/04/base.rb
|
60
|
-
- lib/net/sftp/protocol/04/name.rb
|
61
|
-
- lib/net/sftp/protocol/05/base.rb
|
62
|
-
- lib/net/sftp/protocol/06/attributes.rb
|
63
|
-
- lib/net/sftp/protocol/06/base.rb
|
64
|
-
- lib/net/sftp/protocol/base.rb
|
65
|
-
- lib/net/sftp/protocol.rb
|
66
|
-
- lib/net/sftp/request.rb
|
67
|
-
- lib/net/sftp/response.rb
|
68
|
-
- lib/net/sftp/session.rb
|
69
|
-
- lib/net/sftp/version.rb
|
70
|
-
- lib/net/sftp.rb
|
95
|
+
extra_rdoc_files:
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.rdoc
|
98
|
+
files:
|
99
|
+
- CHANGES.txt
|
100
|
+
- LICENSE.txt
|
101
|
+
- Manifest
|
71
102
|
- README.rdoc
|
72
|
-
|
73
|
-
-
|
103
|
+
- Rakefile
|
104
|
+
- gem-public_cert.pem
|
105
|
+
- lib/net/sftp.rb
|
74
106
|
- lib/net/sftp/constants.rb
|
75
107
|
- lib/net/sftp/errors.rb
|
76
108
|
- lib/net/sftp/operations/dir.rb
|
@@ -79,6 +111,7 @@ files:
|
|
79
111
|
- lib/net/sftp/operations/file_factory.rb
|
80
112
|
- lib/net/sftp/operations/upload.rb
|
81
113
|
- lib/net/sftp/packet.rb
|
114
|
+
- lib/net/sftp/protocol.rb
|
82
115
|
- lib/net/sftp/protocol/01/attributes.rb
|
83
116
|
- lib/net/sftp/protocol/01/base.rb
|
84
117
|
- lib/net/sftp/protocol/01/name.rb
|
@@ -91,14 +124,11 @@ files:
|
|
91
124
|
- lib/net/sftp/protocol/06/attributes.rb
|
92
125
|
- lib/net/sftp/protocol/06/base.rb
|
93
126
|
- lib/net/sftp/protocol/base.rb
|
94
|
-
- lib/net/sftp/protocol.rb
|
95
127
|
- lib/net/sftp/request.rb
|
96
128
|
- lib/net/sftp/response.rb
|
97
129
|
- lib/net/sftp/session.rb
|
98
130
|
- lib/net/sftp/version.rb
|
99
|
-
-
|
100
|
-
- Rakefile
|
101
|
-
- README.rdoc
|
131
|
+
- net-sftp.gemspec
|
102
132
|
- setup.rb
|
103
133
|
- test/common.rb
|
104
134
|
- test/protocol/01/test_attributes.rb
|
@@ -124,47 +154,29 @@ files:
|
|
124
154
|
- test/test_response.rb
|
125
155
|
- test/test_session.rb
|
126
156
|
- test/test_upload.rb
|
127
|
-
-
|
128
|
-
|
129
|
-
|
130
|
-
homepage: http://net-ssh.rubyforge.org/sftp
|
131
|
-
licenses: []
|
132
|
-
|
157
|
+
homepage: https://github.com/net-ssh/net-sftp
|
158
|
+
licenses:
|
159
|
+
- MIT
|
133
160
|
post_install_message:
|
134
|
-
rdoc_options:
|
135
|
-
|
136
|
-
- --inline-source
|
137
|
-
- --title
|
138
|
-
- Net-sftp
|
139
|
-
- --main
|
140
|
-
- README.rdoc
|
141
|
-
require_paths:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
142
163
|
- lib
|
143
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
165
|
none: false
|
145
|
-
requirements:
|
146
|
-
- -
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
|
149
|
-
|
150
|
-
- 0
|
151
|
-
version: "0"
|
152
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ! '>='
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
171
|
none: false
|
154
|
-
requirements:
|
155
|
-
- -
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
|
158
|
-
segments:
|
159
|
-
- 1
|
160
|
-
- 2
|
161
|
-
version: "1.2"
|
172
|
+
requirements:
|
173
|
+
- - ! '>='
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
162
176
|
requirements: []
|
163
|
-
|
164
|
-
|
165
|
-
rubygems_version: 1.3.7
|
177
|
+
rubyforge_project: net-sftp
|
178
|
+
rubygems_version: 1.8.25
|
166
179
|
signing_key:
|
167
180
|
specification_version: 3
|
168
181
|
summary: A pure Ruby implementation of the SFTP client protocol
|
169
|
-
test_files:
|
170
|
-
- test/test_all.rb
|
182
|
+
test_files: []
|
metadata.gz.sig
ADDED