]> git.proxmox.com Git - pve-storage.git/commitdiff
archive info: keep some basic strictness
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 15 May 2020 17:18:22 +0000 (19:18 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 15 May 2020 17:18:24 +0000 (19:18 +0200)
we want to enforce at least the strictness that our tools can do
something with a backup archive..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/Storage.pm
test/archive_info_test.pm

index df8d6fe0761ebca270ac4af0035e1512a8e4bf02..f1e3b19b62b322890d6447256e1a9671817bd83b 100755 (executable)
@@ -1394,13 +1394,9 @@ sub archive_info {
     my $info;
 
     my $volid = basename($archive);
-    if ($volid =~ /\.(tgz$|tar|vma)(?:\.(${\PVE::Storage::Plugin::COMPRESSOR_RE}))?$/) {
-       $info = decompressor_info($1, $2);
-       $info->{type} = 'unknown';
-
-       if ($volid =~ /vzdump-(lxc|openvz|qemu)-\d+-(?:\d{4})_(?:\d{2})_(?:\d{2})-(?:\d{2})_(?:\d{2})_(?:\d{2})/) {
-           $info->{type} = $1;
-       }
+    if ($volid =~ /vzdump-(lxc|openvz|qemu)-\d+-.+\.(tgz$|tar|vma)(?:\.(${\PVE::Storage::Plugin::COMPRESSOR_RE}))?$/) {
+       $info = decompressor_info($2, $3);
+       $info->{type} = $1;
     } else {
        die "ERROR: couldn't determine archive info from '$archive'\n";
     }
index dd4a635883be164dde369cfe1029b3d6d20bc589..67c60758a97572648fe93fd3dda3479a81f7da83 100644 (file)
@@ -40,9 +40,9 @@ my $tests = [
     },
     {
        description => 'Backup archive, none, tgz',
-       archive     => "backup/whatever-the-name_is_here.tgz",
+       archive     => "backup/vzdump-qemu-$vmid-whatever-the-name_is_here.tgz",
        expected    => {
-           'type'         => 'unknown',
+           'type'         => 'qemu',
            'format'       => 'tar',
            'decompressor' => ['tar', '-z'],
            'compression'  => 'gz',