From 3bb8802a08b2bd57f82f00d7224ec6890986390b Mon Sep 17 00:00:00 2001 From: Stefan Reiter Date: Wed, 17 Feb 2021 14:32:16 +0100 Subject: [PATCH] format: fix render_bytes with CLIFormatter CLIFormatter passes in an options hash as a second paramter, which so far was ignored. Now that we treat it as a precision parameter, check if it is a hash and extract the option from it before using it. Otherwise perl puts HASH(0x...) into the format and sprintf chokes. Signed-off-by: Stefan Reiter --- src/PVE/Format.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PVE/Format.pm b/src/PVE/Format.pm index ed86029..366bc16 100644 --- a/src/PVE/Format.pm +++ b/src/PVE/Format.pm @@ -64,6 +64,8 @@ sub render_fraction_as_percentage { sub render_bytes { my ($value, $precision) = @_; + $precision = $precision->{precision} if ref($precision) eq 'HASH'; + my @units = qw(B KiB MiB GiB TiB PiB); my $max_unit = 0; -- 2.39.5