updated sysinfo/volumes

Bryan Roe committed Feb 4, 2021 at 23:24 UTC 2739432997e02267cc2af6e170c9bd13d3fd44f4
1 file changed +31 -33
agents/meshcore.js
+31 -33
@@ -1272,8 +1272,10 @@ function onFileWatcher(a, b) {
1272 */
1273
1274 function getSystemInformation(func) {
1275 - try {
1275 + try
1276 + {
1277 var results = { hardware: require('identifiers').get() }; // Hardware info
1278 +
1279 if (results.hardware && results.hardware.windows) {
1280 // Remove extra entries and things that change quickly
1281 var x = results.hardware.windows.osinfo;
@@ -1290,43 +1292,39 @@ function getSystemInformation(func) {
1292 if (results.hardware.windows.partitions) { for (var i in results.hardware.windows.partitions) { delete results.hardware.windows.partitions[i].Node; } }
1293 } catch (e) { }
1294 }
1293 - if (process.platform == 'win32') {
1294 - results.pendingReboot = require('win-info').pendingReboot(); // Pending reboot
1295 - if (require('identifiers').volumes != null) {
1296 - try {
1297 - results.volumes = require('identifiers').volumes();
1298 - }
1299 - catch (e) {
1300 - }
1301 - }
1302 - }
1295 results.hardware.agentvers = process.versions;
1296
1305 - /*
1306 - if (process.platform == 'win32') {
1307 - var defragResult = function (r) {
1308 - if (typeof r == 'object') { results[this.callname] = r; }
1309 - if (this.callname == 'defrag') {
1310 - var pr = require('win-info').installedApps(); // Installed apps
1311 - pr.callname = 'installedApps';
1312 - pr.sessionid = data.sessionid;
1313 - pr.then(defragResult, defragResult);
1314 - }
1315 - else {
1316 - results.winpatches = require('win-info').qfe(); // Windows patches
1297 + if (process.platform == 'win32')
1298 + {
1299 + results.pendingReboot = require('win-info').pendingReboot(); // Pending reboot
1300 +
1301 + if (require('identifiers').volumes_promise != null)
1302 + {
1303 + var p = require('identifiers').volumes_promise();
1304 + p.then(function (res)
1305 + {
1306 + results.volumes = res;
1307 results.hash = require('SHA384Stream').create().syncHash(JSON.stringify(results)).toString('hex');
1308 func(results);
1319 - }
1309 + });
1310 }
1321 - var pr = require('win-info').defrag({ volume: 'C:' }); // Defrag TODO
1322 - pr.callname = 'defrag';
1323 - pr.sessionid = data.sessionid;
1324 - pr.then(defragResult, defragResult);
1325 - } else {
1326 - */
1327 - results.hash = require('SHA384Stream').create().syncHash(JSON.stringify(results)).toString('hex');
1328 - func(results);
1329 - //}
1311 + else if (require('identifiers').volumes != null)
1312 + {
1313 + results.volumes = require('identifiers').volumes();
1314 + results.hash = require('SHA384Stream').create().syncHash(JSON.stringify(results)).toString('hex');
1315 + func(results);
1316 + }
1317 + else
1318 + {
1319 + results.hash = require('SHA384Stream').create().syncHash(JSON.stringify(results)).toString('hex');
1320 + func(results);
1321 + }
1322 + }
1323 + else
1324 + {
1325 + results.hash = require('SHA384Stream').create().syncHash(JSON.stringify(results)).toString('hex');
1326 + func(results);
1327 + }
1328 } catch (e) { func(null, e); }
1329 }
1330