storage: rename REs for iso and vztmpl extensions
these changes make it more clear, how many capture groups each RE inclues. Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
726c432964
commit
cd461a5012
@ -437,12 +437,12 @@ __PACKAGE__->register_method ({
|
||||
my $path;
|
||||
|
||||
if ($content eq 'iso') {
|
||||
if ($filename !~ m![^/]+$PVE::Storage::iso_extension_re$!) {
|
||||
if ($filename !~ m![^/]+$PVE::Storage::ISO_EXT_RE_0$!) {
|
||||
raise_param_exc({ filename => "wrong file extension" });
|
||||
}
|
||||
$path = PVE::Storage::get_iso_dir($cfg, $param->{storage});
|
||||
} elsif ($content eq 'vztmpl') {
|
||||
if ($filename !~ m![^/]+$PVE::Storage::vztmpl_extension_re$!) {
|
||||
if ($filename !~ m![^/]+$PVE::Storage::VZTMPL_EXT_RE_1$!) {
|
||||
raise_param_exc({ filename => "wrong file extension" });
|
||||
}
|
||||
$path = PVE::Storage::get_vztmpl_dir($cfg, $param->{storage});
|
||||
@ -618,12 +618,12 @@ __PACKAGE__->register_method({
|
||||
|
||||
my $path;
|
||||
if ($content eq 'iso') {
|
||||
if ($filename !~ m![^/]+$PVE::Storage::iso_extension_re$!) {
|
||||
if ($filename !~ m![^/]+$PVE::Storage::ISO_EXT_RE_0$!) {
|
||||
raise_param_exc({ filename => "wrong file extension" });
|
||||
}
|
||||
$path = PVE::Storage::get_iso_dir($cfg, $storage);
|
||||
} elsif ($content eq 'vztmpl') {
|
||||
if ($filename !~ m![^/]+$PVE::Storage::vztmpl_extension_re$!) {
|
||||
if ($filename !~ m![^/]+$PVE::Storage::VZTMPL_EXT_RE_1$!) {
|
||||
raise_param_exc({ filename => "wrong file extension" });
|
||||
}
|
||||
$path = PVE::Storage::get_vztmpl_dir($cfg, $storage);
|
||||
|
||||
@ -101,9 +101,15 @@ if ( -d '/usr/share/perl5/PVE/Storage/Custom' ) {
|
||||
# initialize all plugins
|
||||
PVE::Storage::Plugin->init();
|
||||
|
||||
our $iso_extension_re = qr/\.(?:iso|img)/i;
|
||||
# the following REs indicate the number or capture groups via the trailing digit
|
||||
# CAUTION don't forget to update the digits accordingly after messing with the capture groups
|
||||
|
||||
our $vztmpl_extension_re = qr/\.tar\.(gz|xz|zst)/i;
|
||||
our $ISO_EXT_RE_0 = qr/\.(?:iso|img)/i;
|
||||
|
||||
our $VZTMPL_EXT_RE_1 = qr/\.tar\.(gz|xz|zst)/i;
|
||||
|
||||
# FIXME remove with PVE 8.0, add versioned breaks for pve-manager
|
||||
our $vztmpl_extension_re = $VZTMPL_EXT_RE_1;
|
||||
|
||||
# PVE::Storage utility functions
|
||||
|
||||
@ -568,10 +574,10 @@ sub path_to_volume_id {
|
||||
return ('images', $info->{volid});
|
||||
}
|
||||
}
|
||||
} elsif ($path =~ m!^$isodir/([^/]+$iso_extension_re)$!) {
|
||||
} elsif ($path =~ m!^$isodir/([^/]+$ISO_EXT_RE_0)$!) {
|
||||
my $name = $1;
|
||||
return ('iso', "$sid:iso/$name");
|
||||
} elsif ($path =~ m!^$tmpldir/([^/]+$vztmpl_extension_re)$!) {
|
||||
} elsif ($path =~ m!^$tmpldir/([^/]+$VZTMPL_EXT_RE_1)$!) {
|
||||
my $name = $1;
|
||||
return ('vztmpl', "$sid:vztmpl/$name");
|
||||
} elsif ($path =~ m!^$privatedir/(\d+)$!) {
|
||||
|
||||
@ -563,9 +563,9 @@ sub parse_volname {
|
||||
my ($vmid, $name) = ($1, $2);
|
||||
my (undef, $format, $isBase) = parse_name_dir($name);
|
||||
return ('images', $name, $vmid, undef, undef, $isBase, $format);
|
||||
} elsif ($volname =~ m!^iso/([^/]+$PVE::Storage::iso_extension_re)$!) {
|
||||
} elsif ($volname =~ m!^iso/([^/]+$PVE::Storage::ISO_EXT_RE_0)$!) {
|
||||
return ('iso', $1);
|
||||
} elsif ($volname =~ m!^vztmpl/([^/]+$PVE::Storage::vztmpl_extension_re)$!) {
|
||||
} elsif ($volname =~ m!^vztmpl/([^/]+$PVE::Storage::VZTMPL_EXT_RE_1)$!) {
|
||||
return ('vztmpl', $1);
|
||||
} elsif ($volname =~ m!^rootdir/(\d+)$!) {
|
||||
return ('rootdir', $1, $1);
|
||||
@ -1141,12 +1141,12 @@ my $get_subdir_files = sub {
|
||||
my $info;
|
||||
|
||||
if ($tt eq 'iso') {
|
||||
next if $fn !~ m!/([^/]+$PVE::Storage::iso_extension_re)$!i;
|
||||
next if $fn !~ m!/([^/]+$PVE::Storage::ISO_EXT_RE_0)$!i;
|
||||
|
||||
$info = { volid => "$sid:iso/$1", format => 'iso' };
|
||||
|
||||
} elsif ($tt eq 'vztmpl') {
|
||||
next if $fn !~ m!/([^/]+$PVE::Storage::vztmpl_extension_re)$!;
|
||||
next if $fn !~ m!/([^/]+$PVE::Storage::VZTMPL_EXT_RE_1)$!;
|
||||
|
||||
$info = { volid => "$sid:vztmpl/$1", format => "t$2" };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user