Blame SOURCES/virt-manager-progress-Fix-showing-correct-final-total.patch

d80d1f
From 3702eed072ae7b2d52398a3c9b1c1feb04ffdce3 Mon Sep 17 00:00:00 2001
d80d1f
From: Cole Robinson <crobinso@redhat.com>
d80d1f
Date: Wed, 14 Dec 2022 12:57:10 -0500
d80d1f
Subject: [PATCH] progress: Fix showing correct final total
d80d1f
d80d1f
Reproducer:
d80d1f
Reproducer:
d80d1f
./virt-install --connect test:///default \
d80d1f
               --location tests/data/fakemedia/fake-f26-netinst.iso
d80d1f
d80d1f
Before:
d80d1f
Starting install...
d80d1f
Retrieving 'vmlinuz'                            |    0 B  00:00:00 ...
d80d1f
Retrieving 'initrd.img'                         |    0 B  00:00:00 ...
d80d1f
d80d1f
After:
d80d1f
Starting install...
d80d1f
Retrieving 'vmlinuz'                            |    9 B  00:00:00 ...
d80d1f
Retrieving 'initrd.img'                         |    9 B  00:00:00 ...
d80d1f
d80d1f
progress.end() currently only reports the total amount of bytes
d80d1f
that were last written to the UI. It should report the total amount
d80d1f
that's been passed to update().
d80d1f
d80d1f
Reported-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
d80d1f
Signed-off-by: Cole Robinson <crobinso@redhat.com>
d80d1f
(cherry picked from commit 4114fa1aa827b836d3a1d11c2ac2d367c9bb0463)
d80d1f
d80d1f
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2156247
d80d1f
d80d1f
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
d80d1f
---
d80d1f
 tests/data/meter/meter1.txt | 2 +-
d80d1f
 tests/data/meter/meter2.txt | 2 +-
d80d1f
 tests/data/meter/meter3.txt | 2 +-
d80d1f
 tests/data/meter/meter5.txt | 2 +-
d80d1f
 tests/data/meter/meter6.txt | 2 +-
d80d1f
 tests/test_misc.py          | 4 +++-
d80d1f
 virtinst/_progresspriv.py   | 4 ++--
d80d1f
 7 files changed, 10 insertions(+), 8 deletions(-)
d80d1f
d80d1f
diff --git a/tests/data/meter/meter1.txt b/tests/data/meter/meter1.txt
d80d1f
index a3f7c7d2f..7e154c972 100644
d80d1f
--- a/tests/data/meter/meter1.txt
d80d1f
+++ b/tests/data/meter/meter1.txt
d80d1f
@@ -9,4 +9,4 @@ Meter text test            20% [===              ]  413 B/s | 2.0 kB  00:19 ETA
d80d1f
 
d80d1f
 Meter text test            40% [======-          ]  731 B/s | 3.9 kB  00:08 ETA 
d80d1f
 
d80d1f
-Meter text test                                             | 3.9 kB  00:04 ... 
d80d1f
+Meter text test                                             | 4.4 kB  00:04 ... 
d80d1f
diff --git a/tests/data/meter/meter2.txt b/tests/data/meter/meter2.txt
d80d1f
index 93e93dc31..7ccc31636 100644
d80d1f
--- a/tests/data/meter/meter2.txt
d80d1f
+++ b/tests/data/meter/meter2.txt
d80d1f
@@ -9,4 +9,4 @@ Meter text test                               20% [=======
d80d1f
 
d80d1f
 Meter text test                               40% [==============                     ]  731 B/s | 3.9 kB  00:00:08 ETA 
d80d1f
 
d80d1f
-Meter text test                                                                                  | 3.9 kB  00:00:04 ... 
d80d1f
+Meter text test                                                                                  | 4.4 kB  00:00:04 ... 
d80d1f
diff --git a/tests/data/meter/meter3.txt b/tests/data/meter/meter3.txt
d80d1f
index 474e40f74..6f66608fe 100644
d80d1f
--- a/tests/data/meter/meter3.txt
d80d1f
+++ b/tests/data/meter/meter3.txt
d80d1f
@@ -4,4 +4,4 @@ Meter text test                                      67 B/s |  200 B  00:02
d80d1f
 Meter text test                                     413 B/s | 2.0 kB  00:03     
d80d1f
 Meter text test                                     731 B/s | 3.9 kB  00:04     
d80d1f
 
d80d1f
-Meter text test                                             | 3.9 kB  00:04     
d80d1f
+Meter text test                                             | 4.4 kB  00:04     
d80d1f
diff --git a/tests/data/meter/meter5.txt b/tests/data/meter/meter5.txt
d80d1f
index 1d232a5de..7142a9718 100644
d80d1f
--- a/tests/data/meter/meter5.txt
d80d1f
+++ b/tests/data/meter/meter5.txt
d80d1f
@@ -9,4 +9,4 @@ Meter text test           1000% [================]  413 B/s | 2.0 kB  --:-- ETA
d80d1f
 
d80d1f
 Meter text test           2000% [================]  731 B/s | 3.9 kB  --:-- ETA 
d80d1f
 
d80d1f
-Meter text test                                             | 3.9 kB  00:04 !!! 
d80d1f
+Meter text test                                             | 4.4 kB  00:04 !!! 
d80d1f
diff --git a/tests/data/meter/meter6.txt b/tests/data/meter/meter6.txt
d80d1f
index 07d99bfd8..dd5d3d47b 100644
d80d1f
--- a/tests/data/meter/meter6.txt
d80d1f
+++ b/tests/data/meter/meter6.txt
d80d1f
@@ -9,4 +9,4 @@ Meter text test            100% [================]  413 B/s | 2.0 kB  --:-- ETA
d80d1f
 
d80d1f
 Meter text test            100% [================]  731 B/s | 3.9 kB  --:-- ETA 
d80d1f
 
d80d1f
-Meter text test                                             | 3.9 kB  00:04     
d80d1f
+Meter text test                                             | 4.4 kB  00:04     
d80d1f
diff --git a/tests/test_misc.py b/tests/test_misc.py
d80d1f
index aa610f4df..20f5a626b 100644
d80d1f
--- a/tests/test_misc.py
d80d1f
+++ b/tests/test_misc.py
d80d1f
@@ -178,7 +178,9 @@ def test_misc_meter():
d80d1f
             m.update(2000)
d80d1f
         with unittest.mock.patch("time.time", return_value=5.0):
d80d1f
             m.update(4000)
d80d1f
-        with unittest.mock.patch("time.time", return_value=6.0):
d80d1f
+        with unittest.mock.patch("time.time", return_value=5.1):
d80d1f
+            m.update(4500)
d80d1f
+        with unittest.mock.patch("time.time", return_value=5.5):
d80d1f
             m.end()
d80d1f
 
d80d1f
     # Basic output testing
d80d1f
diff --git a/virtinst/_progresspriv.py b/virtinst/_progresspriv.py
d80d1f
index 5a31a18cc..a035c9c43 100644
d80d1f
--- a/virtinst/_progresspriv.py
d80d1f
+++ b/virtinst/_progresspriv.py
d80d1f
@@ -112,10 +112,10 @@ class BaseMeter:
d80d1f
         assert type(amount_read) is int
d80d1f
 
d80d1f
         now = time.time()
d80d1f
+        self.last_amount_read = amount_read
d80d1f
+        self.re.update(amount_read, now)
d80d1f
         if (not self.last_update_time or
d80d1f
                 (now >= self.last_update_time + self.update_period)):
d80d1f
-            self.re.update(amount_read, now)
d80d1f
-            self.last_amount_read = amount_read
d80d1f
             self.last_update_time = now
d80d1f
             self._do_update(amount_read)
d80d1f
 
d80d1f
-- 
d80d1f
2.39.0
d80d1f