systeminformation 6.0.0-beta.13 → 6.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/common/filesys.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare const parseZpoolStatus: (stdout: string) => Map<string, {
|
|
|
34
34
|
}>;
|
|
35
35
|
export declare const parseZpoolList: (stdout: string) => Map<string, number>;
|
|
36
36
|
export declare const btrfsProfileFromEntries: (entries: string[]) => string;
|
|
37
|
+
export declare const btrfsUsableSize: (profile: string, sizes: number[]) => number;
|
|
37
38
|
export declare const applyPoolsLinux: (data: FsBlockDevicesData[], pools: PoolInfoLinux[]) => FsBlockDevicesData[];
|
|
38
39
|
export declare const parseZfsMountpoints: (content: string) => Map<string, string>;
|
|
39
40
|
export declare const zfsPoolsLinux: (data: FsBlockDevicesData[]) => Promise<PoolInfoLinux[]>;
|
package/dist/common/filesys.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.btrfsPoolsLinux = exports.zfsPoolsLinux = exports.parseZfsMountpoints = exports.applyPoolsLinux = exports.btrfsProfileFromEntries = exports.parseZpoolList = exports.parseZpoolStatus = exports.matchDevicesWin = exports.matchDevicesLinux = exports.raidMatchLinux = exports.parseLinuxBlk = exports.blkStdoutToObject = exports.calcDiskIO = exports._disk_io = exports.calcFsSpeed = exports._fs_speed = exports.smartMonToolsInstalled = exports.zfsDatasets = void 0;
|
|
3
|
+
exports.btrfsPoolsLinux = exports.zfsPoolsLinux = exports.parseZfsMountpoints = exports.applyPoolsLinux = exports.btrfsUsableSize = exports.btrfsProfileFromEntries = exports.parseZpoolList = exports.parseZpoolStatus = exports.matchDevicesWin = exports.matchDevicesLinux = exports.raidMatchLinux = exports.parseLinuxBlk = exports.blkStdoutToObject = exports.calcDiskIO = exports._disk_io = exports.calcFsSpeed = exports._fs_speed = exports.smartMonToolsInstalled = exports.zfsDatasets = void 0;
|
|
4
4
|
const promises_1 = require("node:fs/promises");
|
|
5
5
|
const index_1 = require("./index");
|
|
6
6
|
const const_1 = require("./const");
|
|
@@ -370,6 +370,27 @@ exports.parseZpoolList = parseZpoolList;
|
|
|
370
370
|
const BTRFS_PROFILES = ['raid1c4', 'raid1c3', 'raid10', 'raid0', 'raid5', 'raid6', 'raid1', 'dup', 'single'];
|
|
371
371
|
const btrfsProfileFromEntries = (entries) => BTRFS_PROFILES.find((profile) => entries.includes(profile)) || '';
|
|
372
372
|
exports.btrfsProfileFromEntries = btrfsProfileFromEntries;
|
|
373
|
+
const btrfsUsableSize = (profile, sizes) => {
|
|
374
|
+
const sum = sizes.reduce((total, size) => total + size, 0);
|
|
375
|
+
const largest = [...sizes].sort((a, b) => b - a);
|
|
376
|
+
switch (profile) {
|
|
377
|
+
case 'dup':
|
|
378
|
+
case 'raid1':
|
|
379
|
+
case 'raid10':
|
|
380
|
+
return Math.floor(sum / 2);
|
|
381
|
+
case 'raid1c3':
|
|
382
|
+
return Math.floor(sum / 3);
|
|
383
|
+
case 'raid1c4':
|
|
384
|
+
return Math.floor(sum / 4);
|
|
385
|
+
case 'raid5':
|
|
386
|
+
return sum - (largest[0] || 0);
|
|
387
|
+
case 'raid6':
|
|
388
|
+
return sum - (largest[0] || 0) - (largest[1] || 0);
|
|
389
|
+
default:
|
|
390
|
+
return sum;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
exports.btrfsUsableSize = btrfsUsableSize;
|
|
373
394
|
const applyPoolsLinux = (data, pools) => {
|
|
374
395
|
const defaults = (0, index_1.cloneObj)(defaults_1.initFsBlockDevice);
|
|
375
396
|
const result = [...data];
|
|
@@ -467,7 +488,7 @@ const btrfsPoolsLinux = async (data) => {
|
|
|
467
488
|
name: label || fsid,
|
|
468
489
|
type: profile || 'btrfs',
|
|
469
490
|
fsType: 'btrfs',
|
|
470
|
-
size: members.
|
|
491
|
+
size: (0, exports.btrfsUsableSize)(profile, members.map((element) => element.size)),
|
|
471
492
|
uuid: fsid,
|
|
472
493
|
mount: members.find((element) => element.mount)?.mount || '',
|
|
473
494
|
members: devices
|
|
@@ -23,6 +23,7 @@ export declare const stringStartWith: (searchString: string, position?: number)
|
|
|
23
23
|
export declare const mathMin: (...values: number[]) => number;
|
|
24
24
|
export declare const sanitizeShellString: (str: string, strict?: any) => string;
|
|
25
25
|
export declare const isSafePathSegment: (segment: string) => boolean;
|
|
26
|
+
export declare const sanitizeDriveLetter: (str: string) => string;
|
|
26
27
|
export declare const sanitizeContainerID: (str: string) => string;
|
|
27
28
|
export declare const sanitizeImageID: (str: string) => string;
|
|
28
29
|
export declare const isPrototypePolluted: () => boolean;
|
package/dist/common/security.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sanitizeString = exports.sanitizeInterfacesString = exports.sanitizeServiceString = exports.sanitizeUrl = exports.isPrototypePolluted = exports.sanitizeImageID = exports.sanitizeContainerID = exports.isSafePathSegment = exports.sanitizeShellString = exports.mathMin = exports.stringStartWith = exports.stringSplit = exports.stringTrim = exports.stringSubstring = exports.stringSubstr = exports.stringToString = exports.stringToLower = exports.stringReplace = void 0;
|
|
3
|
+
exports.sanitizeString = exports.sanitizeInterfacesString = exports.sanitizeServiceString = exports.sanitizeUrl = exports.isPrototypePolluted = exports.sanitizeImageID = exports.sanitizeContainerID = exports.sanitizeDriveLetter = exports.isSafePathSegment = exports.sanitizeShellString = exports.mathMin = exports.stringStartWith = exports.stringSplit = exports.stringTrim = exports.stringSubstring = exports.stringSubstr = exports.stringToString = exports.stringToLower = exports.stringReplace = void 0;
|
|
4
4
|
exports.stringReplace = new String().replace;
|
|
5
5
|
exports.stringToLower = new String().toLowerCase;
|
|
6
6
|
exports.stringToString = new String().toString;
|
|
@@ -58,6 +58,11 @@ const sanitizeShellString = (str, strict) => {
|
|
|
58
58
|
exports.sanitizeShellString = sanitizeShellString;
|
|
59
59
|
const isSafePathSegment = (segment) => !!segment && segment.indexOf('/') === -1 && segment.indexOf('\0') === -1 && segment !== '.' && segment !== '..';
|
|
60
60
|
exports.isSafePathSegment = isSafePathSegment;
|
|
61
|
+
const sanitizeDriveLetter = (str) => {
|
|
62
|
+
const match = /^\s*([a-zA-Z]):?[\\/]?\s*$/.exec(String(str || ''));
|
|
63
|
+
return match ? `${match[1]}:` : '';
|
|
64
|
+
};
|
|
65
|
+
exports.sanitizeDriveLetter = sanitizeDriveLetter;
|
|
61
66
|
const sanitizeContainerID = (str) => {
|
|
62
67
|
const s = String(str || '')
|
|
63
68
|
.substring(0, 2000)
|
package/dist/linux/fs-size.js
CHANGED
|
@@ -67,9 +67,9 @@ const parseNixFsSize = (lines) => {
|
|
|
67
67
|
const fsType = withType ? match[2] : macOsFsType(fs);
|
|
68
68
|
const mount = (withType ? match[6] : match[5]).trim();
|
|
69
69
|
if (fs.startsWith('/') || mount === '/' || fs.indexOf('/') > 0 || fs.indexOf(':') === 1 || (!const_1.DARWIN && !isLinuxTmpFs(fsType))) {
|
|
70
|
-
const size = (0, common_1.toInt)(match[withType ? 3 : 2]) * 1024;
|
|
71
70
|
const used = (0, common_1.toInt)(match[withType ? 4 : 3]) * 1024;
|
|
72
71
|
const available = (0, common_1.toInt)(match[withType ? 5 : 4]) * 1024;
|
|
72
|
+
const size = fsType === 'btrfs' ? used + available : (0, common_1.toInt)(match[withType ? 3 : 2]) * 1024;
|
|
73
73
|
const use = parseFloat((100.0 * (used / (used + available))).toFixed(2));
|
|
74
74
|
const rw = osMounts && Object.keys(osMounts).length > 0 ? osMounts[fs] || false : null;
|
|
75
75
|
if (!data.find((el) => el.fs === fs && el.type === fsType && el.mount === mount)) {
|
|
@@ -143,12 +143,13 @@ const linuxFsSize = async (drives) => {
|
|
|
143
143
|
}
|
|
144
144
|
try {
|
|
145
145
|
const [stats, { dev }] = await Promise.all([(0, promises_1.statfs)(mount), (0, promises_1.stat)(mount)]);
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
146
|
+
const rawSize = stats.blocks * stats.bsize;
|
|
147
|
+
if (!rawSize) {
|
|
148
148
|
continue;
|
|
149
149
|
}
|
|
150
150
|
const used = (stats.blocks - stats.bfree) * stats.bsize;
|
|
151
151
|
const available = stats.bavail * stats.bsize;
|
|
152
|
+
const size = type === 'btrfs' ? used + available : rawSize;
|
|
152
153
|
const item = {
|
|
153
154
|
dev,
|
|
154
155
|
entry: {
|
package/dist/windows/fs-size.js
CHANGED
|
@@ -33,10 +33,7 @@ const fsSize = async (drives) => {
|
|
|
33
33
|
await (0, common_1.nextTick)();
|
|
34
34
|
let data = [];
|
|
35
35
|
try {
|
|
36
|
-
const conditions = drives
|
|
37
|
-
.map((drive) => (drive ? (0, security_1.sanitizeShellString)(drive, true) : ''))
|
|
38
|
-
.filter((drive) => drive !== '')
|
|
39
|
-
.map((drive) => `$_.Caption -eq '${drive}'`);
|
|
36
|
+
const conditions = drives.filter((drive) => !!drive).map((drive) => `$_.Caption -eq '${(0, security_1.sanitizeDriveLetter)(drive)}'`);
|
|
40
37
|
const filter = conditions.length ? ` | where { ${conditions.join(' -or ')} }` : '';
|
|
41
38
|
const stdout = await windows_1.ps.exec(`Get-CimInstance Win32_logicaldisk | select Access,Caption,FileSystem,FreeSpace,Size${filter} | fl`);
|
|
42
39
|
data = parseFsSize(String(stdout));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.14",
|
|
4
4
|
"description": "Advanced, lightweight system and OS information library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|