[pve-devel] [PATCH: proxmox-widget-toolkit] parse_task_upid: Allow additional (optional) task_id field

dietmar at proxmox.com dietmar at proxmox.com
Tue Dec 17 11:46:11 CET 2019


From: Dietmar Maurer <dietmar at proxmox.com>

We need that if tasks runs inside multi-threaded applications (several
tasks inside one process).
---
 Utils.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Utils.js b/Utils.js
index 1fa6999..6d1b24c 100644
--- a/Utils.js
+++ b/Utils.js
@@ -589,17 +589,20 @@ Ext.define('Proxmox.Utils', { utilities: {
     parse_task_upid: function(upid) {
 	var task = {};
 
-	var res = upid.match(/^UPID:(\S+):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8,9}):([0-9A-Fa-f]{8}):([^:\s]+):([^:\s]*):([^:\s]+):$/);
+	var res = upid.match(/^UPID:([^\s:]+):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8,9}):(([0-9A-Fa-f]{8,16}):)?([0-9A-Fa-f]{8}):([^:\s]+):([^:\s]*):([^:\s]+):$/);
 	if (!res) {
 	    throw "unable to parse upid '" + upid + "'";
 	}
 	task.node = res[1];
 	task.pid = parseInt(res[2], 16);
 	task.pstart = parseInt(res[3], 16);
-	task.starttime = parseInt(res[4], 16);
-	task.type = res[5];
-	task.id = res[6];
-	task.user = res[7];
+	if (res[5] !== undefined) {
+	    task.task_id = parseInt(res[5], 16);
+	}
+	task.starttime = parseInt(res[6], 16);
+	task.type = res[7];
+	task.id = res[8];
+	task.user = res[9];
 
 	task.desc = Proxmox.Utils.format_task_description(task.type, task.id);
 
-- 
2.20.1




More information about the pve-devel mailing list