This patch is quite hard to read. I guess it would make sense to
split this and do the function rename as extra patch?

Some questions below:

> -my $replace_file_names_with_contents = sub {
> +my $replace_mapped_contents = sub {
>      my ($param, $mapping) = @_;
>  
>      if ($mapping) {
>       foreach my $elem ( @$mapping ) {
> -         $param->{$elem} = PVE::Tools::file_get_contents($param->{$elem})
> -             if defined($param->{$elem});
> +         my $mapfunc = sub { return PVE::Tools::file_get_contents($_[0]) };

why define $mapfunc, and why here? Simply use:

my $mapfunc;

> +         if (ref($elem) eq 'ARRAY') {
> +             ($elem, $mapfunc) = @$elem;

you overwrite here anyways.

> +         }
> +         if (defined(my $value = $param->{$elem})) {
> +             $param->{$elem} = $mapfunc->($value);

                $param->{$elem} = PVE::Tools::file_get_contents($value) 

> +         }
>       }
>      }

_______________________________________________
pve-devel mailing list
[email protected]
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to