]> git.proxmox.com Git - pve-manager.git/commitdiff
vzdump: prepare 'exclude-path' for array format
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 12 May 2023 12:23:51 +0000 (14:23 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 5 Jun 2023 08:01:45 +0000 (10:01 +0200)
we want to move the 'exclude-path' to an array format (from 'string-alist')
prepare the code that it can be either a string or a list

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/VZDump.pm

index a04837e7e8f502753eaa18e9308da1de82694307..dde3475629f9999d0383d13cafb297cb8d47106b 100644 (file)
@@ -279,7 +279,15 @@ sub read_vzdump_defaults {
     my $conf_schema = { type => 'object', properties => $confdesc_for_defaults };
     my $res = PVE::JSONSchema::parse_config($conf_schema, $fn, $raw);
     if (my $excludes = $res->{'exclude-path'}) {
-       $res->{'exclude-path'} = PVE::Tools::split_args($excludes);
+       if (ref($excludes) eq 'ARRAY') {
+           my $list = [];
+           for my $path ($excludes->@*) {
+               push $list->@*, PVE::Tools::split_args($path)->@*;
+           }
+           $res->{'exclude-path'} = $list;
+       } else {
+           $res->{'exclude-path'} = PVE::Tools::split_args($excludes);
+       }
     }
     if (defined($res->{mailto})) {
        my @mailto = split_list($res->{mailto});
@@ -1339,10 +1347,15 @@ sub option_exists {
 sub parse_mailto_exclude_path {
     my ($param) = @_;
 
-    # exclude-path list need to be 0 separated
+    # exclude-path list need to be 0 separated or be an array
     if (defined($param->{'exclude-path'})) {
-       my @expaths = split(/\0/, $param->{'exclude-path'} || '');
-       $param->{'exclude-path'} = [ @expaths ];
+       my $expaths;
+       if (ref($param->{'exclude-path'}) eq 'ARRAY') {
+           $expaths = $param->{'exclude-path'};
+       } else {
+           $expaths = [split(/\0/, $param->{'exclude-path'} || '')];
+       }
+       $param->{'exclude-path'} = $expaths;
     }
 
     if (defined($param->{mailto})) {