miga-base 1.3.15.8 → 1.3.15.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/miga/cli/action/db.rb +7 -2
- data/lib/miga/common.rb +10 -2
- data/lib/miga/version.rb +1 -1
- data/test/common_test.rb +8 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 064e93465ac48e77eb31406064706cc7a10e1b34b73fea9216a7759f23f4982c
|
4
|
+
data.tar.gz: 2818f9708bfbaa8e43f6742c5bfb963a00f68737a07b4afdb3a693ce58a49f40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6b8df2cfd819f69fcc5bf922d0a57d0cb33f48a4bf6371fc1a5433c9571902ca3f1ed8a8c7df5c1df2b35f05da820545b51e046e60ba692eeff7e77e46d1699
|
7
|
+
data.tar.gz: '024922760df8f9cffdc72fb96df36fe8d4805b41b885164280af6633cf45f6da95fa5cb647d44a8149d1e81026d41e397888c453f97adc0ee7ea176b50ff6507'
|
data/lib/miga/cli/action/db.rb
CHANGED
@@ -139,7 +139,7 @@ class MiGA::Cli::Action::Db < MiGA::Cli::Action
|
|
139
139
|
MiGA::MiGA.download_file_ftp(ftp, path, file) do |n, size|
|
140
140
|
cli.advance("#{path}:", n, size) if cli[:pb]
|
141
141
|
end
|
142
|
-
cli.
|
142
|
+
cli.say '' if cli[:pb]
|
143
143
|
end
|
144
144
|
file
|
145
145
|
end
|
@@ -225,11 +225,16 @@ class MiGA::Cli::Action::Db < MiGA::Cli::Action
|
|
225
225
|
cli.say 'Checking MD5 digest'
|
226
226
|
cli.say "Expected: #{ver[:MD5]}"
|
227
227
|
md5 = Digest::MD5.new
|
228
|
+
size = File.size(file)
|
229
|
+
n = 0
|
228
230
|
File.open(file, 'rb') do |fh|
|
229
231
|
until fh.eof?
|
230
|
-
md5
|
232
|
+
md5 << fh.read(1024)
|
233
|
+
n += 1024
|
234
|
+
cli.advance('Processed:', [n, size].min, size) if cli[:pb]
|
231
235
|
end
|
232
236
|
end
|
237
|
+
cli.say '' if cli[:pb]
|
233
238
|
dig = md5.hexdigest
|
234
239
|
cli.say "Observed: #{dig}"
|
235
240
|
raise 'Corrupt file, MD5 does not match' unless dig == ver[:MD5]
|
data/lib/miga/common.rb
CHANGED
@@ -64,25 +64,33 @@ class MiGA::MiGA
|
|
64
64
|
# The report goes to $stderr iff --verbose
|
65
65
|
def advance(step, n = 0, total = nil, bin = true)
|
66
66
|
# Initialize advance timing
|
67
|
-
@_advance_time ||= { last: nil, n: 0, avg: nil }
|
68
|
-
if @_advance_time[:n] > n
|
67
|
+
@_advance_time ||= { last: nil, n: 0, avg: nil, total: total }
|
68
|
+
if @_advance_time[:n] > n || total != @_advance_time[:total]
|
69
69
|
@_advance_time[:last] = nil
|
70
70
|
@_advance_time[:n] = 0
|
71
71
|
@_advance_time[:avg] = nil
|
72
|
+
@_advance_time[:total] = total
|
72
73
|
end
|
73
74
|
|
74
75
|
# Estimate timing
|
75
76
|
adv_n = n - @_advance_time[:n]
|
76
77
|
if total.nil? || @_advance_time[:last].nil? || adv_n.negative?
|
78
|
+
# Initial report
|
77
79
|
@_advance_time[:last] = Time.now
|
78
80
|
@_advance_time[:n] = n
|
79
81
|
elsif adv_n > 0.001 * total
|
82
|
+
# Advance report (if change > 0.1% change and time > 1 second)
|
80
83
|
this_time = (Time.now - @_advance_time[:last]).to_f
|
84
|
+
return if this_time < 1.0 && n < total
|
85
|
+
|
81
86
|
this_avg = this_time / adv_n
|
82
87
|
@_advance_time[:avg] ||= this_avg
|
83
88
|
@_advance_time[:avg] = 0.9 * @_advance_time[:avg] + 0.1 * this_avg
|
84
89
|
@_advance_time[:last] = Time.now
|
85
90
|
@_advance_time[:n] = n
|
91
|
+
else
|
92
|
+
# Final report (if the last update was too small) or ignore update
|
93
|
+
return if n < total
|
86
94
|
end
|
87
95
|
|
88
96
|
# Report
|
data/lib/miga/version.rb
CHANGED
@@ -12,7 +12,7 @@ module MiGA
|
|
12
12
|
# - String indicating release status:
|
13
13
|
# - rc* release candidate, not released as gem
|
14
14
|
# - [0-9]+ stable release, released as gem
|
15
|
-
VERSION = [1.3, 15,
|
15
|
+
VERSION = [1.3, 15, 9].freeze
|
16
16
|
|
17
17
|
##
|
18
18
|
# Nickname for the current major.minor version.
|
data/test/common_test.rb
CHANGED
@@ -76,23 +76,26 @@ class CommonTest < Test::Unit::TestCase
|
|
76
76
|
def test_advance
|
77
77
|
m = MiGA::MiGA.new
|
78
78
|
|
79
|
-
# Check advance when missing total
|
79
|
+
# Check advance when missing total and n
|
80
80
|
o = capture_stderr { m.advance('x', 0) }.string
|
81
81
|
assert_match(%r{\] x *\r}, o)
|
82
82
|
|
83
|
+
# Check advance when missing total
|
84
|
+
o = capture_stderr { m.advance('x', 10) }.string
|
85
|
+
assert_match(%r{\] x 10 *\r}, o)
|
86
|
+
|
83
87
|
# Initialize advance
|
84
88
|
o = capture_stderr { m.advance('x', 0, 1001) }.string
|
85
89
|
assert_match(%r{\] x 0\.0% \(0/1001\) *\r}, o)
|
86
90
|
|
87
91
|
# Insufficient data for prediction
|
88
|
-
sleep(1)
|
89
92
|
o = capture_stderr { m.advance('x', 1, 1000) }.string
|
90
93
|
assert_match(%r{\] x 0\.1% \(1/1000\) *\r}, o)
|
91
94
|
|
92
95
|
# Predict time
|
93
|
-
sleep(1)
|
94
|
-
o = capture_stderr { m.advance('x',
|
95
|
-
assert_match(%r{\] x 0\.
|
96
|
+
sleep(1.01)
|
97
|
+
o = capture_stderr { m.advance('x', 4, 1000) }.string
|
98
|
+
assert_match(%r{\] x 0\.4% \(4/1000\) \d\.\dm left *\r}, o)
|
96
99
|
end
|
97
100
|
|
98
101
|
def test_num_suffix
|