Commit f8087e0f ("ui: fix regression with checking if volume is QEMU
backup") opted for making the function support multiple types of
callers making the function more complex than it needs to be. Simply
adapt the rest of the call sites that the commit introducing the
regression missed, i.e. commit 3f8246030 ("ui: backup: also check for
backup subtype to classify archive").

By always checking the subtype, this also makes the function work
correctly should there ever be another storage type supporting file
restore  with different format names than PBS or volid patterns than
directory storages.

Signed-off-by: Fiona Ebner <f.eb...@proxmox.com>
---
 www/manager6/Utils.js              | 15 +++------------
 www/manager6/grid/BackupView.js    |  2 +-
 www/manager6/storage/BackupView.js |  2 +-
 3 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 1f6778cd..63f6b2ce 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -694,18 +694,9 @@ Ext.define('PVE.Utils', {
        'import': gettext('Import'),
     },
 
-     // volume can be a full volume info object, in which case the format 
parameter is ignored, or
-     // you can pass the volume ID and format as separate string parameters.
-    volume_is_qemu_backup: function(volume, format) {
-       let volid, subtype;
-       if (typeof volume === 'string') {
-           volid = volume;
-       } else if (typeof volume === 'object') {
-           ({ volid, format, subtype } = volume);
-       } else {
-           console.error("internal error - unexpected type", volume);
-       }
-       return format === 'pbs-vm' || volid.match(':backup/vzdump-qemu-') || 
subtype === 'qemu';
+    volume_is_qemu_backup: function(volume) {
+       return volume.format === 'pbs-vm' || 
volume.volid.match(':backup/vzdump-qemu-') ||
+           volume.subtype === 'qemu';
     },
 
     volume_is_lxc_backup: function(volume) {
diff --git a/www/manager6/grid/BackupView.js b/www/manager6/grid/BackupView.js
index 0f68a25e..610dda8d 100644
--- a/www/manager6/grid/BackupView.js
+++ b/www/manager6/grid/BackupView.js
@@ -244,7 +244,7 @@ Ext.define('PVE.grid.BackupView', {
            hidden: !isPBS,
            handler: function(b, e, rec) {
                let storage = storagesel.getValue();
-               let isVMArchive = 
PVE.Utils.volume_is_qemu_backup(rec.data.volid, rec.data.format);
+               let isVMArchive = PVE.Utils.volume_is_qemu_backup(rec.data);
                Ext.create('Proxmox.window.FileBrowser', {
                    title: gettext('File Restore') + " - " + rec.data.text,
                    listURL: 
`/api2/json/nodes/localhost/storage/${storage}/file-restore/list`,
diff --git a/www/manager6/storage/BackupView.js 
b/www/manager6/storage/BackupView.js
index 749c2136..1247be81 100644
--- a/www/manager6/storage/BackupView.js
+++ b/www/manager6/storage/BackupView.js
@@ -115,7 +115,7 @@ Ext.define('PVE.storage.BackupView', {
                disabled: true,
                selModel: sm,
                handler: function(b, e, rec) {
-                   let isVMArchive = 
PVE.Utils.volume_is_qemu_backup(rec.data.volid, rec.data.format);
+                   let isVMArchive = PVE.Utils.volume_is_qemu_backup(rec.data);
                    Ext.create('Proxmox.window.FileBrowser', {
                        title: gettext('File Restore') + " - " + rec.data.text,
                        listURL: 
`/api2/json/nodes/localhost/storage/${me.storage}/file-restore/list`,
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to