[pve-devel] [PATCH storage v2 1/3] compact regex for backup file filter

Dominic Jäger d.jaeger at proxmox.com
Thu Feb 13 08:27:51 CET 2020


On Wed, Feb 12, 2020 at 11:19:06AM +0100, Thomas Lamprecht wrote:
> On 1/31/20 5:00 PM, Alwin Antreich wrote:
> > --- a/PVE/Storage/Plugin.pm
> > +++ b/PVE/Storage/Plugin.pm
> > @@ -423,7 +423,7 @@ sub parse_volname {
> >  	return ('vztmpl', $1);
> >      } elsif ($volname =~ m!^rootdir/(\d+)$!) {
> >  	return ('rootdir', $1, $1);
> > -    } elsif ($volname =~ m!^backup/([^/]+(\.(tar|tar\.gz|tar\.lzo|tgz|vma|vma\.gz|vma\.lzo)))$!) {
> > +    } elsif ($volname =~ m!^backup/([^/]+(\.(tgz|((tar|vma)(\.(gz|lzo))?))))$!) {
> >  	my $fn = $1;
> >  	if ($fn =~ m/^vzdump-(openvz|lxc|qemu)-(\d+)-.+/) {
> >  	    return ('backup', $fn, $2);
> > @@ -910,7 +910,7 @@ my $get_subdir_files = sub {
> >  
> >  	} elsif ($tt eq 'backup') {
> >  	    next if defined($vmid) && $fn !~  m/\S+-$vmid-\S+/;
> > -	    next if $fn !~ m!/([^/]+\.(tar|tar\.gz|tar\.lzo|tgz|vma|vma\.gz|vma\.lzo))$!;
> > +	    next if $fn !~ m!/([^/]+\.(tgz|((tar|vma)(\.(gz|lzo))?)))$!;
> >  
> >  	    $info = { volid => "$sid:backup/$1", format => $2 };
> writing test for this up front as a first patch would be great.
> It should be pretty simple, i.e., have a array of maps with params and expected
> result as two key => value entries. Additionally "expected error" checks would be
> great too.
> While there's already a sub test in zfspoolplugin test I'd just do a new one.
> 
> This way we would have a safety net for such and future changes.

There are no negative tests or maps, but I once posted some tests for parse_volname
[0] to the list. Maybe they could be a starting point.

[0] https://pve.proxmox.com/pipermail/pve-devel/2019-December/040887.html



More information about the pve-devel mailing list