Fixup prettyBytes
This commit is contained in:
@@ -62,13 +62,13 @@ function getRootPath(apiConfig) {
|
||||
}
|
||||
|
||||
// binary units (non SI) 1024 based
|
||||
function prettyBytes(size) {
|
||||
assert.strictEqual(typeof size, 'number');
|
||||
function prettyBytes(bytes) {
|
||||
assert.strictEqual(typeof bytes, 'number');
|
||||
|
||||
if (!size) return 0;
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(1024)),
|
||||
sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
const i = Math.floor(Math.log(size) / Math.log(1024));
|
||||
return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
||||
return (bytes / Math.pow(1024, i)).toFixed(2) * 1 + '' + sizes[i];
|
||||
}
|
||||
|
||||
// the du call in the function below requires root
|
||||
|
||||
Reference in New Issue
Block a user