[pve-devel] [PATCH storage 6/6] archive info: keep some basic strictness

Thomas Lamprecht t.lamprecht at proxmox.com
Fri May 15 19:23:44 CEST 2020


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 at proxmox.com>
---
 PVE/Storage.pm            | 10 +++-------
 test/archive_info_test.pm |  4 ++--
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index df8d6fe..f1e3b19 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -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";
     }
diff --git a/test/archive_info_test.pm b/test/archive_info_test.pm
index dd4a635..67c6075 100644
--- a/test/archive_info_test.pm
+++ b/test/archive_info_test.pm
@@ -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',
-- 
2.20.1





More information about the pve-devel mailing list