updater: better error message

This commit is contained in:
Girish Ramakrishnan
2023-01-30 12:54:25 +01:00
parent 5fc92240bb
commit af7a5d2182
3 changed files with 14 additions and 13 deletions
+12 -1
View File
@@ -2,13 +2,24 @@
exports = module.exports = {
disks,
file
file,
prettyBytes
};
const assert = require('assert'),
BoxError = require('./boxerror.js'),
safe = require('safetydance');
// binary units (non SI) 1024 based
function prettyBytes(bytes) {
assert.strictEqual(typeof bytes, 'number');
const i = Math.floor(Math.log(bytes) / Math.log(1024)),
sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
return (bytes / Math.pow(1024, i)).toFixed(2) * 1 + '' + sizes[i];
}
function parseLine(line) {
const parts = line.split(/\s+/, 7); // this way the mountpoint can have spaces in it