From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 2CE8D1FF165
	for <inbox@lore.proxmox.com>; Thu, 10 Apr 2025 09:17:21 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id EA58C1FA69;
	Thu, 10 Apr 2025 09:17:14 +0200 (CEST)
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Thu, 10 Apr 2025 09:16:38 +0200
Message-Id: <20250410071638.11497-1-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.39.5
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.036 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH manager] ui: util: simplify
 volume_is_qemu_backup again
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

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