fix mac volume detection for older os
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
May 14, 2024 at 10:11 UTC
23ee76e26a957d440bbdbe12a48eaf7511a49730
1 file changed
+23
-1
agents/modules_meshcore/computer-identifiers.js
+23
-1
@@ -717,7 +717,29 @@ function macos_identifiers()
717
child.stdout.str = ''; child.stdout.on('data', dataHandler);
718
child.stdin.write('df -aHY | awk \'NR>1 {printf "{\\"size\\":\\"%s\\",\\"used\\":\\"%s\\",\\"available\\":\\"%s\\",\\"mount_point\\":\\"%s\\",\\"type\\":\\"%s\\"},", $3, $4, $5, $10, $2}\' | sed \'$ s/,$//\' | awk \'BEGIN {printf "["} {printf "%s", $0} END {printf "]"}\'\nexit\n');
719
child.waitExit();
720
- try { ret.darwin.volumes = JSON.parse(child.stdout.str.trim()); } catch (xx) { }
720
+ try {
721
+ ret.darwin.volumes = JSON.parse(child.stdout.str.trim());
722
+ for (var index = 0; index < ret.darwin.volumes.length; index++) {
723
+ if (ret.darwin.volumes[index].type == 'auto_home'){
724
+ ret.darwin.volumes.splice(index,1);
725
+ }
726
+ }
727
+ if (ret.darwin.volumes.length == 0) { // not sonima OS so dont show type for now
728
+ child = require('child_process').execFile('/bin/sh', ['sh']);
729
+ child.stdout.str = ''; child.stdout.on('data', dataHandler);
730
+ child.stdin.write('df -aH | awk \'NR>1 {printf "{\\"size\\":\\"%s\\",\\"used\\":\\"%s\\",\\"available\\":\\"%s\\",\\"mount_point\\":\\"%s\\"},", $2, $3, $4, $9}\' | sed \'$ s/,$//\' | awk \'BEGIN {printf "["} {printf "%s", $0} END {printf "]"}\'\nexit\n');
731
+ child.waitExit();
732
+ try {
733
+ ret.darwin.volumes = JSON.parse(child.stdout.str.trim());
734
+ for (var index = 0; index < ret.darwin.volumes.length; index++) {
735
+ sendConsoleText(ret.darwin.volumes[index].size);
736
+ if (ret.darwin.volumes[index].size == 'auto_home'){
737
+ ret.darwin.volumes.splice(index,1);
738
+ }
739
+ }
740
+ } catch (xx) { }
741
+ }
742
+ } catch (xx) { }
743
child = null;
744
745
// MacOS Last Boot Up Time