mirror of
https://git.proxmox.com/git/pve-guest-common
synced 2025-08-15 02:40:23 +00:00
followup: rename to print_snapshot_tree, add comment and rename $res param
This was taken from a CLI helper, there $res is a common parameter name which denotes that it's the res from the API call the CLI command bases on. But here that makes no sense and is not really telling about what the value(s) of $res could be. Further explain that with a comment. As this also prints uncoditionally to STDOUT let's say so through the method name. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
725dcadba3
commit
5ee5f8873e
@ -62,13 +62,15 @@ sub exec_hookscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub snapshot_tree {
|
# takes a snapshot list (e.g., qm/pct snapshot_list API call result) and
|
||||||
my ($res) = @_;
|
# prints it out in a nice tree sorted by age. Can cope with multiple roots
|
||||||
|
sub print_snapshot_tree {
|
||||||
|
my ($snapshot_list) = @_;
|
||||||
|
|
||||||
my $snapshots = { map { $_->{name} => $_ } @$res };
|
my $snapshots = { map { $_->{name} => $_ } @$snapshot_list };
|
||||||
|
|
||||||
my @roots;
|
my @roots;
|
||||||
foreach my $e (@$res) {
|
foreach my $e (@$snapshot_list) {
|
||||||
my $parent;
|
my $parent;
|
||||||
if (($parent = $e->{parent}) && defined $snapshots->{$parent}) {
|
if (($parent = $e->{parent}) && defined $snapshots->{$parent}) {
|
||||||
push @{$snapshots->{$parent}->{children}}, $e->{name};
|
push @{$snapshots->{$parent}->{children}}, $e->{name};
|
||||||
|
Loading…
Reference in New Issue
Block a user