]> git.proxmox.com Git - pve-guest-common.git/commitdiff
refactor print_pending_delete slightly
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Oct 2019 15:15:46 +0000 (17:15 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Oct 2019 15:48:03 +0000 (17:48 +0200)
while this was much better than the old mess from
parse_pending_delete it still was a bit much nested into one line.

split that up a bit, add a render_key helper which does the clunky
"add !" check and just call that one in the map {}

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/AbstractConfig.pm

index 16ba427e96485aeb8a14266f0e247220390e6715..055bd74027eb092b165cdbe8075f365f9ff5fada 100644 (file)
@@ -92,7 +92,14 @@ sub parse_pending_delete {
 
 sub print_pending_delete {
     my ($class, $delete_hash) = @_;
-    join ",", map { ( $delete_hash->{$_}->{force} ? '!' : '' ) . $_ } keys %$delete_hash;
+
+    my $render_key = sub {
+       my $key = shift;
+       $key = "!$key" if $delete_hash->{$key}->{force};
+       return $key;
+    };
+
+    join (',', map { $render_key->($_) } keys %$delete_hash);
 }
 
 sub add_to_pending_delete {