]> git.proxmox.com Git - pve-common.git/commitdiff
format: fix render_bytes with CLIFormatter
authorStefan Reiter <s.reiter@proxmox.com>
Wed, 17 Feb 2021 13:32:16 +0000 (14:32 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 25 Feb 2021 20:20:59 +0000 (21:20 +0100)
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 <s.reiter@proxmox.com>
src/PVE/Format.pm

index ed860291d7df7704cde86ec81eb156fe5c3c7f57..366bc161a0514a5139356c6e0839c3b6c7a7efd5 100644 (file)
@@ -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;