]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/Plugin.pm
list volumes: also return backup type for backups
[pve-storage.git] / PVE / Storage / Plugin.pm
index 12f1b4bb8336db350cda6dd38b0fac6dee2b1ab1..667340908f84e410726e75e125a36724392f00a1 100644 (file)
@@ -563,13 +563,13 @@ 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);
-    } elsif ($volname =~ m!^backup/([^/]+(?:\.(?:tgz|(?:(?:tar|vma)(?:\.(?:${\COMPRESSOR_RE}))?))))$!) {
+    } elsif ($volname =~ m!^backup/([^/]+$PVE::Storage::BACKUP_EXT_RE_2)$!) {
        my $fn = $1;
        if ($fn =~ m/^vzdump-(openvz|lxc|qemu)-(\d+)-.+/) {
            return ('backup', $fn, $2);
@@ -892,7 +892,11 @@ sub file_size_info {
     my ($size, $format, $used, $parent) = $info->@{qw(virtual-size format actual-size backing-filename)};
 
     ($size) = ($size =~ /^(\d+)$/) or die "size '$size' not an integer\n"; # untaint
+    # coerce back from string
+    $size = int($size);
     ($used) = ($used =~ /^(\d+)$/) or die "used '$used' not an integer\n"; # untaint
+    # coerce back from string
+    $used = int($used);
     ($format) = ($format =~ /^(\S+)$/) or die "format '$format' includes whitespace\n"; # untaint
     if (defined($parent)) {
        ($parent) = ($parent =~ /^(\S+)$/) or die "parent '$parent' includes whitespace\n"; # untaint
@@ -1137,17 +1141,17 @@ 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" };
 
        } elsif ($tt eq 'backup') {
-           next if $fn !~ m!/([^/]+\.(tgz|(?:(?:tar|vma)(?:\.(${\COMPRESSOR_RE}))?)))$!;
+           next if $fn !~ m!/([^/]+$PVE::Storage::BACKUP_EXT_RE_2)$!;
            my $original = $fn;
            my $format = $2;
            $fn = $1;
@@ -1160,6 +1164,7 @@ my $get_subdir_files = sub {
            my $archive_info = eval { PVE::Storage::archive_info($fn) } // {};
 
            $info->{ctime} = $archive_info->{ctime} if defined($archive_info->{ctime});
+           $info->{subtype} = $archive_info->{type} // 'unknown';
 
            if (defined($vmid) || $fn =~ m!\-([1-9][0-9]{2,8})\-[^/]+\.${format}$!) {
                $info->{vmid} = $vmid // $1;