]> git.proxmox.com Git - pve-guest-common.git/commitdiff
refactor/cleanup remove_from_pending_delete sligthly
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Oct 2019 17:44:40 +0000 (19:44 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Oct 2019 17:44:42 +0000 (19:44 +0200)
return $conf for tests, use intermediate variable for
$conf->{pending}, which besides shorter lines avoids also the
autovification of $config stuff.

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

index b07ef5936131c95dbf517ac9c683b9c6a0c6b69b..71a9e7c243f919d567f3b92c094dde7ed80d2bbe 100644 (file)
@@ -119,14 +119,20 @@ sub add_to_pending_delete {
 sub remove_from_pending_delete {
     my ($class, $conf, $key) = @_;
 
-    my $pending_delete_hash = $class->parse_pending_delete($conf->{pending}->{delete});
+    my $pending = $conf->{pending};
+    my $pending_delete_hash = $class->parse_pending_delete($pending->{delete});
+
+    return $conf if ! exists $pending_delete_hash->{$key};
+
     delete $pending_delete_hash->{$key};
 
     if (%$pending_delete_hash) {
-       $conf->{pending}->{delete} = $class->print_pending_delete($pending_delete_hash);
+       $pending->{delete} = $class->print_pending_delete($pending_delete_hash);
     } else {
-       delete $conf->{pending}->{delete};
+       delete $pending->{delete};
     }
+
+    return $conf;
 }
 
 sub cleanup_pending {