net-scp 4.2.1 → 4.2.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.txt +5 -0
- data/lib/net/scp/download.rb +15 -1
- data/lib/net/scp/upload.rb +15 -5
- data/lib/net/scp/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d9333fc8b5f1e6a3ef2ac8e0cac2da60439a1a007c0d3f4cdde1f65d9a8b15e
|
|
4
|
+
data.tar.gz: 71a0e15c9061385b5c3f22b224859ba6d0afb841889210ca21a1e02bef3b3f37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1fefda923541258a50e80a72412331e1ecf253778912cb4d2baaf75f66010fca666075a8c9fef45a68f133a442e2fb43de54a94cb5ffdd8977e1a9aab9ebf801
|
|
7
|
+
data.tar.gz: 47e43e791e8939779334280c4593a74d739076d5a690286557ae4d0b4fbc7ba6b0d798656b85b931812a328ecfd0c14b9457f7447095a5c27289840d4d29b6fe
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGES.txt
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
=== 4.2.2
|
|
2
|
+
|
|
3
|
+
* Downloads into an IO-like object whose `write` returns a partial byte count now retry until the whole chunk is written, instead of reporting success with only part of the file stored; a count of zero, a negative one or one larger than the chunk raises `Net::SCP::Error`. Thanks @OskarEichler [#121, #99]
|
|
4
|
+
* Uploads now send exactly the number of bytes announced to the server, counted in bytes rather than characters: data a source gains after the size is taken is not sent, and a source that ends early or a reader returning more than requested raises `Net::SCP::Error` instead of completing a short or overlong transfer. Previously the extra bytes of an overlong upload could be read by the server as the next SCP command. Thanks @OskarEichler [#120, #98]
|
|
5
|
+
|
|
1
6
|
=== 4.2.1
|
|
2
7
|
|
|
3
8
|
* Add a `:limit` option to `upload`/`download` to cap bandwidth in Kbit/s, like `scp -l`. Based on #53 by @marcelrouw [#119, #53]
|
data/lib/net/scp/download.rb
CHANGED
|
@@ -67,12 +67,26 @@ module Net; class SCP
|
|
|
67
67
|
def read_data_state(channel)
|
|
68
68
|
return if channel[:buffer].empty?
|
|
69
69
|
data = channel[:buffer].read!(channel[:remaining])
|
|
70
|
-
channel
|
|
70
|
+
write_fully(channel, data)
|
|
71
71
|
channel[:remaining] -= data.length
|
|
72
72
|
progress_callback(channel, channel[:file][:name], channel[:file][:size] - channel[:remaining], channel[:file][:size])
|
|
73
73
|
await_response(channel, :finish_read) if channel[:remaining] <= 0
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
+
# Writes +data+ to the local IO, retrying after partial writes. A write
|
|
77
|
+
# returning something other than an Integer is taken to have written all
|
|
78
|
+
# of it, as for sinks like uri/open-scp's that return the buffer.
|
|
79
|
+
def write_fully(channel, data)
|
|
80
|
+
until data.empty?
|
|
81
|
+
written = channel[:io].write(data)
|
|
82
|
+
return unless written.is_a?(Integer)
|
|
83
|
+
unless written > 0 && written <= data.bytesize
|
|
84
|
+
raise Net::SCP::Error, "#{channel[:file][:name]}: write returned #{written} for #{data.bytesize} bytes"
|
|
85
|
+
end
|
|
86
|
+
data = data.byteslice(written..-1)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
76
90
|
# Finishes off the read, sets the times for the file (if any), and then
|
|
77
91
|
# jumps to either #finish_state (for single-file downloads) or
|
|
78
92
|
# #read_directive_state (for recursive downloads). A 0-byte is sent to the
|
data/lib/net/scp/upload.rb
CHANGED
|
@@ -70,16 +70,26 @@ module Net; class SCP
|
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
# If any
|
|
74
|
-
# Otherwise, sends a 0-byte and
|
|
73
|
+
# If any of the announced bytes remain to be transferred from the current
|
|
74
|
+
# file, sends the next chunk of them. Otherwise, sends a 0-byte and
|
|
75
|
+
# transfers to #next_item_state. Data beyond the size announced in the 'C'
|
|
76
|
+
# directive is never read, as the server would take it as the next directive.
|
|
75
77
|
def send_data_state(channel)
|
|
76
|
-
|
|
77
|
-
if
|
|
78
|
+
remaining = channel[:size] - channel[:sent]
|
|
79
|
+
if remaining <= 0
|
|
78
80
|
channel[:io].close unless channel[:local].respond_to?(:read)
|
|
79
81
|
channel.send_data("\0")
|
|
80
82
|
await_response(channel, :next_item)
|
|
81
83
|
else
|
|
82
|
-
channel[:
|
|
84
|
+
length = [channel[:chunk_size], remaining].min
|
|
85
|
+
data = channel[:io].read(length)
|
|
86
|
+
if data.nil? || data.empty?
|
|
87
|
+
raise Net::SCP::Error, "#{channel[:name]}: source ended after #{channel[:sent]} of #{channel[:size]} bytes"
|
|
88
|
+
elsif data.bytesize > length
|
|
89
|
+
raise Net::SCP::Error, "#{channel[:name]}: read returned #{data.bytesize} bytes, more than the #{length} requested"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
channel[:sent] += data.bytesize
|
|
83
93
|
progress_callback(channel, channel[:name], channel[:sent], channel[:size])
|
|
84
94
|
channel.send_data(data)
|
|
85
95
|
end
|
data/lib/net/scp/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: net-scp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.2.
|
|
4
|
+
version: 4.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jamis Buck
|
|
@@ -32,7 +32,7 @@ cert_chain:
|
|
|
32
32
|
vNiMFH5yLu/tlav4xh+HlYscWVdFQIvd7f/Uxa+Vip1Pi16wmhnrE15z/vDX921v
|
|
33
33
|
hukBRIoCEAuUgNVBh+L/C8aETzbf/77WU3Si/w==
|
|
34
34
|
-----END CERTIFICATE-----
|
|
35
|
-
date: 2026-11-
|
|
35
|
+
date: 2026-11-09 00:00:00.000000000 Z
|
|
36
36
|
dependencies:
|
|
37
37
|
- !ruby/object:Gem::Dependency
|
|
38
38
|
name: net-ssh
|
metadata.gz.sig
CHANGED
|
Binary file
|