110 lines
4.8 KiB
Diff
110 lines
4.8 KiB
Diff
Subject: progress: Fix showing correct final total
|
|
From: Cole Robinson crobinso@redhat.com Wed Dec 14 12:57:10 2022 -0500
|
|
Date: Wed Dec 14 13:01:48 2022 -0500:
|
|
Git: 4114fa1aa827b836d3a1d11c2ac2d367c9bb0463
|
|
|
|
Reproducer:
|
|
Reproducer:
|
|
./virt-install --connect test:///default \
|
|
--location tests/data/fakemedia/fake-f26-netinst.iso
|
|
|
|
Before:
|
|
Starting install...
|
|
Retrieving 'vmlinuz' | 0 B 00:00:00 ...
|
|
Retrieving 'initrd.img' | 0 B 00:00:00 ...
|
|
|
|
After:
|
|
Starting install...
|
|
Retrieving 'vmlinuz' | 9 B 00:00:00 ...
|
|
Retrieving 'initrd.img' | 9 B 00:00:00 ...
|
|
|
|
progress.end() currently only reports the total amount of bytes
|
|
that were last written to the UI. It should report the total amount
|
|
that's been passed to update().
|
|
|
|
Reported-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
|
|
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
|
|
|
diff --git a/tests/data/meter/meter1.txt b/tests/data/meter/meter1.txt
|
|
index a3f7c7d2..7e154c97 100644
|
|
--- a/tests/data/meter/meter1.txt
|
|
+++ b/tests/data/meter/meter1.txt
|
|
@@ -9,4 +9,4 @@ Meter text test 20% [=== ] 413 B/s | 2.0 kB 00:19 ETA
|
|
|
|
Meter text test 40% [======- ] 731 B/s | 3.9 kB 00:08 ETA
|
|
|
|
-Meter text test | 3.9 kB 00:04 ...
|
|
+Meter text test | 4.4 kB 00:04 ...
|
|
diff --git a/tests/data/meter/meter2.txt b/tests/data/meter/meter2.txt
|
|
index 93e93dc3..7ccc3163 100644
|
|
--- a/tests/data/meter/meter2.txt
|
|
+++ b/tests/data/meter/meter2.txt
|
|
@@ -9,4 +9,4 @@ Meter text test 20% [=======
|
|
|
|
Meter text test 40% [============== ] 731 B/s | 3.9 kB 00:00:08 ETA
|
|
|
|
-Meter text test | 3.9 kB 00:00:04 ...
|
|
+Meter text test | 4.4 kB 00:00:04 ...
|
|
diff --git a/tests/data/meter/meter3.txt b/tests/data/meter/meter3.txt
|
|
index 474e40f7..6f66608f 100644
|
|
--- a/tests/data/meter/meter3.txt
|
|
+++ b/tests/data/meter/meter3.txt
|
|
@@ -4,4 +4,4 @@ Meter text test 67 B/s | 200 B 00:02
|
|
Meter text test 413 B/s | 2.0 kB 00:03
|
|
Meter text test 731 B/s | 3.9 kB 00:04
|
|
|
|
-Meter text test | 3.9 kB 00:04
|
|
+Meter text test | 4.4 kB 00:04
|
|
diff --git a/tests/data/meter/meter5.txt b/tests/data/meter/meter5.txt
|
|
index 1d232a5d..7142a971 100644
|
|
--- a/tests/data/meter/meter5.txt
|
|
+++ b/tests/data/meter/meter5.txt
|
|
@@ -9,4 +9,4 @@ Meter text test 1000% [================] 413 B/s | 2.0 kB --:-- ETA
|
|
|
|
Meter text test 2000% [================] 731 B/s | 3.9 kB --:-- ETA
|
|
|
|
-Meter text test | 3.9 kB 00:04 !!!
|
|
+Meter text test | 4.4 kB 00:04 !!!
|
|
diff --git a/tests/data/meter/meter6.txt b/tests/data/meter/meter6.txt
|
|
index 07d99bfd..dd5d3d47 100644
|
|
--- a/tests/data/meter/meter6.txt
|
|
+++ b/tests/data/meter/meter6.txt
|
|
@@ -9,4 +9,4 @@ Meter text test 100% [================] 413 B/s | 2.0 kB --:-- ETA
|
|
|
|
Meter text test 100% [================] 731 B/s | 3.9 kB --:-- ETA
|
|
|
|
-Meter text test | 3.9 kB 00:04
|
|
+Meter text test | 4.4 kB 00:04
|
|
diff --git a/tests/test_misc.py b/tests/test_misc.py
|
|
index aa610f4d..20f5a626 100644
|
|
--- a/tests/test_misc.py
|
|
+++ b/tests/test_misc.py
|
|
@@ -178,7 +178,9 @@ def test_misc_meter():
|
|
m.update(2000)
|
|
with unittest.mock.patch("time.time", return_value=5.0):
|
|
m.update(4000)
|
|
- with unittest.mock.patch("time.time", return_value=6.0):
|
|
+ with unittest.mock.patch("time.time", return_value=5.1):
|
|
+ m.update(4500)
|
|
+ with unittest.mock.patch("time.time", return_value=5.5):
|
|
m.end()
|
|
|
|
# Basic output testing
|
|
diff --git a/virtinst/_progresspriv.py b/virtinst/_progresspriv.py
|
|
index 5a31a18c..a035c9c4 100644
|
|
--- a/virtinst/_progresspriv.py
|
|
+++ b/virtinst/_progresspriv.py
|
|
@@ -112,10 +112,10 @@ class BaseMeter:
|
|
assert type(amount_read) is int
|
|
|
|
now = time.time()
|
|
+ self.last_amount_read = amount_read
|
|
+ self.re.update(amount_read, now)
|
|
if (not self.last_update_time or
|
|
(now >= self.last_update_time + self.update_period)):
|
|
- self.re.update(amount_read, now)
|
|
- self.last_amount_read = amount_read
|
|
self.last_update_time = now
|
|
self._do_update(amount_read)
|
|
|