]> git.proxmox.com Git - qemu-server.git/commitdiff
restore: refactor archive parsing
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 20 Jun 2023 07:41:48 +0000 (09:41 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Jun 2023 17:40:26 +0000 (19:40 +0200)
to avoid duplicate work, always set 'volid' to the backup volume's volid, if it
was successfully parsed as such.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/API2/Qemu.pm

index d0c199bfa7d637de9a0c4655d56a53771751c0de..b7832d8821a8eeabaa662d53d78af75693a71a98 100644 (file)
@@ -750,20 +750,20 @@ my $parse_restore_archive = sub {
 
     my ($archive_storeid, $archive_volname) = PVE::Storage::parse_volume_id($archive, 1);
 
+    my $res = {};
+
     if (defined($archive_storeid)) {
        my $scfg =  PVE::Storage::storage_config($storecfg, $archive_storeid);
+       $res->{volid} = $archive;
        if ($scfg->{type} eq 'pbs') {
-           return {
-               type => 'pbs',
-               volid => $archive,
-           };
+           $res->{type} = 'pbs';
+           return $res;
        }
     }
     my $path = PVE::Storage::abs_filesystem_path($storecfg, $archive);
-    return {
-       type => 'file',
-       path => $path,
-    };
+    $res->{type} = 'file';
+    $res->{path} = $path;
+    return $res;
 };