From 3451ed1a91b4f4ea3e643d7662540a765680bdac Mon Sep 17 00:00:00 2001 From: ma Date: Tue, 19 Mar 2024 11:10:29 +0100 Subject: [PATCH] #160: fix progressbar values --- Changelog | 6 ++++++ libvirtnbdbackup/backup/disk.py | 4 ++-- libvirtnbdbackup/chunk.py | 2 +- libvirtnbdbackup/common.py | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 30bddb6a..338f76ef 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,9 @@ +Version 2.1 +--------- + * Fix Progressbar: Since change for issue #133 the Progressbar was + updated with wrong values and as result progressed too fast for the amount of + data actually written. + Version 2.0 --------- * Update README diff --git a/libvirtnbdbackup/backup/disk.py b/libvirtnbdbackup/backup/disk.py index 2e20c49a..442226bc 100644 --- a/libvirtnbdbackup/backup/disk.py +++ b/libvirtnbdbackup/backup/disk.py @@ -169,6 +169,8 @@ def backup( # pylint: disable=too-many-arguments,too-many-branches, too-many-lo if streamType == "raw": size = writer.seek(save.offset) + progressBar.update(save.length) + if streamType == "stream": writer.write(sTypes.TERM) if args.compress: @@ -181,8 +183,6 @@ def backup( # pylint: disable=too-many-arguments,too-many-branches, too-many-lo compressedSizes.append(size) else: assert size == save.length - - progressBar.update(save.length) else: if streamType == "raw": writer.seek(save.offset) diff --git a/libvirtnbdbackup/chunk.py b/libvirtnbdbackup/chunk.py index b131b518..c5cac5f6 100644 --- a/libvirtnbdbackup/chunk.py +++ b/libvirtnbdbackup/chunk.py @@ -54,7 +54,7 @@ def write( else: wSize += writer.write(data) - pbar.update(wSize) + pbar.update(blocklen) return wSize, cSizes diff --git a/libvirtnbdbackup/common.py b/libvirtnbdbackup/common.py index 6f1b416f..50334028 100644 --- a/libvirtnbdbackup/common.py +++ b/libvirtnbdbackup/common.py @@ -224,6 +224,7 @@ def progressBar(total: int, desc: str, args: Namespace, count=0) -> tqdm: desc=desc, unit="B", unit_scale=True, + unit_divisor=1000, disable=args.noprogress, position=count, leave=False,