From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BC7A272EC1 for ; Wed, 26 May 2021 15:48:15 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6882012F23 for ; Wed, 26 May 2021 15:48:15 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D61F012EA2 for ; Wed, 26 May 2021 15:48:12 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A3DBA46677 for ; Wed, 26 May 2021 15:48:12 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Wed, 26 May 2021 15:48:09 +0200 Message-Id: <20210526134811.333-8-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210526134811.333-1-d.csapak@proxmox.com> References: <20210526134811.333-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.034 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 7/9] ui: tape/TapeRestore: don't send snapshotlist when restoring whole datastores X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 May 2021 13:48:15 -0000 for the case that the user selects only whole datastores, we do not want to send and (exhaustive) list of snapshots that get restored, but we only want to honor the mapping the user gives this avoids using the backup restore codepath that iterates twice over the tapes and would generally be slower for a lot of snapshots Signed-off-by: Dominik Csapak --- www/tape/window/TapeRestore.js | 57 +++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/www/tape/window/TapeRestore.js b/www/tape/window/TapeRestore.js index 1987dff4..35619957 100644 --- a/www/tape/window/TapeRestore.js +++ b/www/tape/window/TapeRestore.js @@ -184,9 +184,13 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', { values = []; } let datastores = {}; - values.forEach((snapshot) => { - const [datastore] = snapshot.split(':'); - datastores[datastore] = true; + values.forEach((snapshotOrDatastore) => { + let datastore = snapshotOrDatastore; + if (snapshotOrDatastore.indexOf(':') !== -1) { + let snapshot = snapshotOrDatastore; + let match = snapshot.split(':'); + datastore = match[0]; + } datastores[datastore] = true; }); me.setDataStores(Object.keys(datastores)); @@ -230,7 +234,7 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', { if (response.result.data.length > 0) { grid.setDisabled(false); grid.setVisible(true); - grid.getStore().setData(response.result.data); + grid.setData(response.result.data); grid.getSelectionModel().selectAll(); // we've shown a big list, center the window again view.center(); @@ -294,10 +298,14 @@ Ext.define('PBS.TapeManagement.TapeRestoreWindow', { onGetValues: function(values) { let me = this; - if (values.snapshots === 'all') { - delete values.snapshots; - } else if (Ext.isString(values.snapshots) && values.snapshots) { + if (values !== "all" && + Ext.isString(values.snapshots) && + values.snapshots && + values.snapshots.indexOf(':') !== -1 + ) { values.snapshots = values.snapshots.split(','); + } else { + delete values.snapshots; } return values; @@ -593,6 +601,8 @@ Ext.define('PBS.TapeManagement.SnapshotGrid', { let me = this; let snapshots = []; + let storeCounts = {}; + me.getSelection().forEach((rec) => { let id = rec.get('id'); let store = rec.data.store; @@ -600,6 +610,10 @@ Ext.define('PBS.TapeManagement.SnapshotGrid', { // only add if not filtered if (me.store.findExact('id', id) !== -1) { snapshots.push(`${store}:${snap}`); + if (storeCounts[store] === undefined) { + storeCounts[store] = 0; + } + storeCounts[store]++; } }); @@ -610,6 +624,21 @@ Ext.define('PBS.TapeManagement.SnapshotGrid', { return "all"; } + let wholeStores = []; + let wholeStoresSelected = true; + for (const [store, count] of Object.entries(storeCounts)) { + if (me.storeCounts[store] === count) { + wholeStores.push(store); + } else { + wholeStoresSelected = false; + break; + } + } + + if (wholeStoresSelected) { + return wholeStores; + } + return snapshots; }, @@ -639,6 +668,20 @@ Ext.define('PBS.TapeManagement.SnapshotGrid', { return []; }, + setData: function(records) { + let me = this; + let storeCounts = {}; + records.forEach((rec) => { + let store = rec.store; + if (storeCounts[store] === undefined) { + storeCounts[store] = 0; + } + storeCounts[store]++; + }); + me.storeCounts = storeCounts; + me.getStore().setData(records); + }, + scrollable: true, plugins: 'gridfilters', -- 2.20.1