[pbs-devel] [PATCH proxmox-backup] ui: fix crypt mode caluclation

Dominik Csapak d.csapak at proxmox.com
Thu Jul 9 16:50:24 CEST 2020


also include 'mixed' in the calculation of the overall mode of a
snapshot and group

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/DataStoreContent.js | 11 ++++++-----
 www/Utils.js            | 10 ++++++++--
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/www/DataStoreContent.js b/www/DataStoreContent.js
index cc4d955..a29436f 100644
--- a/www/DataStoreContent.js
+++ b/www/DataStoreContent.js
@@ -21,19 +21,19 @@ Ext.define('pbs-data-store-snapshots', {
 		    mixed: 0,
 		    'sign-only': 0,
 		    encrypt: 0,
+		    count: 0,
 		};
 		let signed = 0;
-		let files = 0;
 		data.files.forEach(file => {
 		    if (file.filename === 'index.json.blob') return; // is never encrypted
 		    let mode = PBS.Utils.cryptmap.indexOf(file['crypt-mode']);
 		    if (mode !== -1) {
 			crypt[file['crypt-mode']]++;
 		    }
-		    files++;
+		    crypt.count++;
 		});
 
-		return PBS.Utils.calculateCryptMode(crypt['sign-only'], crypt.encrypt, files);
+		return PBS.Utils.calculateCryptMode(crypt);
 	    }
 	}
     ]
@@ -155,7 +155,7 @@ Ext.define('PBS.DataStoreContent', {
 		    none: 0,
 		    mixed: 0,
 		    'sign-only': 0,
-		    encrypt: 0
+		    encrypt: 0,
 		};
 		for (const item of group.children) {
 		    crypt[PBS.Utils.cryptmap[item['crypt-mode']]]++;
@@ -169,7 +169,8 @@ Ext.define('PBS.DataStoreContent', {
 
 		}
 		group.count = group.children.length;
-		group['crypt-mode'] = PBS.Utils.calculateCryptMode(crypt['sign-only'], crypt.encrypt, group.count);
+		crypt.count = group.count;
+		group['crypt-mode'] = PBS.Utils.calculateCryptMode(crypt);
 		children.push(group);
 	    }
 
diff --git a/www/Utils.js b/www/Utils.js
index db7dbf8..c75a779 100644
--- a/www/Utils.js
+++ b/www/Utils.js
@@ -34,8 +34,14 @@ Ext.define('PBS.Utils', {
 	'lock',
     ],
 
-    calculateCryptMode: function(signed, encrypted, files) {
-	if (files === encrypted) {
+    calculateCryptMode: function(data) {
+	let mixed = data.mixed;
+	let encrypted = data.encrypt;
+	let signed = data['sign-only'];
+	let files = data.count;
+	if (mixed > 0) {
+	    return PBS.Utils.cryptmap.indexOf('mixed');
+	} else if (files === encrypted) {
 	    return PBS.Utils.cryptmap.indexOf('encrypt');
 	} else if (files === signed) {
 	    return PBS.Utils.cryptmap.indexOf('sign-only');
-- 
2.20.1






More information about the pbs-devel mailing list