From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] ui: util: simplify volume_is_qemu_backup again
Date: Thu, 10 Apr 2025 09:16:38 +0200 [thread overview]
Message-ID: <20250410071638.11497-1-f.ebner@proxmox.com> (raw)
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.ebner@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
next reply other threads:[~2025-04-10 7:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 7:16 Fiona Ebner [this message]
[not found] ` <61890f96-5720-4122-be8c-683adebc9f2c@proxmox.com>
2025-04-10 8:29 ` Fiona Ebner
2025-04-10 8:35 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250410071638.11497-1-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal