]> git.proxmox.com Git - pve-guest-common.git/commitdiff
print snapshot tree: clamp indentation length to positive
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 28 Feb 2022 14:46:46 +0000 (15:46 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 1 Mar 2022 11:59:38 +0000 (12:59 +0100)
If a user has many snapshots, the length heuristic can go negative
and produce wrong indentation, so clamp it at 0.

Reported in the forum: https://forum.proxmox.com/threads/105740/

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/GuestHelpers.pm

index 970c460fe4bdda19abb120b3d1f9af508554e12b..0c8ed663b4d8919ed98138344b1127045e8e17c8 100644 (file)
@@ -157,6 +157,7 @@ sub print_snapshot_tree {
        }
 
        my $len = 30 - length($prefix); # for aligning the description
+       $len = 0 if $len < 0;
        printf("%s %-${len}s %-23s %s\n", $prefix, $root, $timestring, $description);
 
        if ($e->{children}) {