From b0d6e968ece909dd2e9c389bd497f8b4e780a03d Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Mon, 9 Nov 2020 07:04:03 +0100 Subject: [PATCH] blockdevices() catching errors --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 2 +- docs/system.html | 10 ++++++++++ lib/filesystem.js | 48 +++++++++++++++++++++++++---------------------- 5 files changed, 43 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b59cc9..f7d8bcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.29.2 | 2020-11-09 | `blockdevices()` catch errors | | 4.29.1 | 2020-11-08 | `cpu()`, `system()` better parsing Raspberry Pi revision codes | | 4.29.0 | 2020-11-08 | `fsSize()` correct fs type detection macOS (HFS, APFS, NFS) | | 4.28.1 | 2020-11-05 | code cleanup, removing debug console.log() | diff --git a/docs/history.html b/docs/history.html index 9d2c5fd..b0a8768 100644 --- a/docs/history.html +++ b/docs/history.html @@ -83,6 +83,11 @@ + + 4.29.2 + 2020-11-09 + blockdevices() catch error + 4.29.1 2020-11-08 diff --git a/docs/index.html b/docs/index.html index 7782f43..f8ae1ac 100644 --- a/docs/index.html +++ b/docs/index.html @@ -168,7 +168,7 @@
systeminformation
-
Current Version: 4.29.1
+
Current Version: 4.29.2
diff --git a/docs/system.html b/docs/system.html index f76a6e2..dcccc35 100644 --- a/docs/system.html +++ b/docs/system.html @@ -135,6 +135,16 @@ SKU number + + + raspberry + X + + + + + Additional Raspberry-specific information
manufacturer, processor, type, revision
Raspberry only + diff --git a/lib/filesystem.js b/lib/filesystem.js index bd62582..0643064 100755 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -268,30 +268,34 @@ function parseDevices(lines) { function parseBlk(lines) { let data = []; - lines.filter(line => line !== '').forEach((line) => { - line = decodeURIComponent(line.replace(/\\x/g, '%')); - line = line.replace(/\\/g, '\\\\'); - let disk = JSON.parse(line); - data.push({ - 'name': disk.name, - 'type': disk.type, - 'fstype': disk.fstype, - 'mount': disk.mountpoint, - 'size': parseInt(disk.size), - 'physical': (disk.type === 'disk' ? (disk.rota === '0' ? 'SSD' : 'HDD') : (disk.type === 'rom' ? 'CD/DVD' : '')), - 'uuid': disk.uuid, - 'label': disk.label, - 'model': disk.model, - 'serial': disk.serial, - 'removable': disk.rm === '1', - 'protocol': disk.tran, - 'group': disk.group, + try { + lines.filter(line => line !== '').forEach((line) => { + line = decodeURIComponent(line.replace(/\\x/g, '%')); + line = line.replace(/\\/g, '\\\\'); + let disk = JSON.parse(line); + data.push({ + 'name': disk.name, + 'type': disk.type, + 'fstype': disk.fstype, + 'mount': disk.mountpoint, + 'size': parseInt(disk.size), + 'physical': (disk.type === 'disk' ? (disk.rota === '0' ? 'SSD' : 'HDD') : (disk.type === 'rom' ? 'CD/DVD' : '')), + 'uuid': disk.uuid, + 'label': disk.label, + 'model': disk.model, + 'serial': disk.serial, + 'removable': disk.rm === '1', + 'protocol': disk.tran, + 'group': disk.group, + }); }); - }); + data = util.unique(data); + data = util.sortByKey(data, ['type', 'name']); + return data; + } catch (e) { + return []; + } - data = util.unique(data); - data = util.sortByKey(data, ['type', 'name']); - return data; } function blkStdoutToObject(stdout) {