[pve-devel] [PATCH manager 2/6] api: backup: update: turn delete into a hash

Fiona Ebner f.ebner at proxmox.com
Wed Nov 16 15:04:31 CET 2022


makes it easier to check for keys in the following patches.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 PVE/API2/Backup.pm | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/PVE/API2/Backup.pm b/PVE/API2/Backup.pm
index 6aef5bb7..1d3d6896 100644
--- a/PVE/API2/Backup.pm
+++ b/PVE/API2/Backup.pm
@@ -435,9 +435,7 @@ __PACKAGE__->register_method({
 
 	my $id = extract_param($param, 'id');
 	my $delete = extract_param($param, 'delete');
-	if ($delete) {
-	    $delete = [PVE::Tools::split_list($delete)];
-	}
+	$delete = { map { $_ => 1 } PVE::Tools::split_list($delete) } if $delete;
 
 	my $update_job = sub {
 	    my $data = cfs_read_file('vzdump.cron');
@@ -472,7 +470,7 @@ __PACKAGE__->register_method({
 		'repeat-missed' => 1,
 	    };
 
-	    foreach my $k (@$delete) {
+	    for my $k (keys $delete->%*) {
 		if (!PVE::VZDump::option_exists($k) && !$deletable->{$k}) {
 		    raise_param_exc({ delete => "unknown option '$k'" });
 		}
-- 
2.30.2






More information about the pve-devel mailing list