[pve-devel] [PATCH storage] fix #2226: ignore broken symlinks in template_list

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jun 13 15:41:29 CEST 2019


On 6/13/19 2:30 PM, Stefan Reiter wrote:
> Broken symlinks will no longer be enumerated, thus not causing a
> format validation in content GUI due to the missing filesize.

so they just get hidden now? Not sure if this is want we want,
one normally may want to make an admin notice a dangling symlink,
or not?

Maybe just do a

$info->{size} = -s $fn // 0;

instead?

FYI: in perl || is a logical or and // is a definedness check,

0 || echo "foo"; # echos foo
0 // echo "foo"; # does _not_ echo foo
undef // echo "foo" # does echo foo
 
> Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
> ---
>  PVE/Storage.pm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index 588e775..4486122 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -869,7 +869,7 @@ sub template_list {
>  
>  		$info->{size} = -s $fn;
>  
> -		push @{$res->{$sid}}, $info;
> +		push @{$res->{$sid}}, $info if $info->{size};
>  	    }
>  
>  	}
> 





More information about the pve-devel mailing list