From ad7cd67c0273b9164ee745528184110821729959 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 30 Aug 2022 15:30:09 -0700 Subject: [PATCH] Fixed details tab not updating on Linux (#4466) --- agents/meshcore.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/agents/meshcore.js b/agents/meshcore.js index bb661d87..6337f741 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -1757,6 +1757,13 @@ function onFileWatcher(a, b) { } */ +// Replace all key name spaces with _ in an object recursively. +// This is a workaround since require('identifiers').get() returns key names with spaces in them on Linux. +function replaceSpacesWithUnderscoresRec(o) { + if (typeof o != 'object') return; + for (var i in o) { if (i.indexOf(' ') >= 0) { o[i.split(' ').join('_')] = o[i]; delete o[i]; } replaceSpacesWithUnderscoresRec(o[i]); } +} + function getSystemInformation(func) { try { var results = { hardware: require('identifiers').get() }; // Hardware info @@ -1778,6 +1785,7 @@ function getSystemInformation(func) { } catch (ex) { } } results.hardware.agentvers = process.versions; + replaceSpacesWithUnderscoresRec(results); var hasher = require('SHA384Stream').create(); results.hash = hasher.syncHash(JSON.stringify(results)).toString('hex'); func(results);