diff --git a/src/storage/filesystem.js b/src/storage/filesystem.js index 41947eaf5..6d50e8f6d 100644 --- a/src/storage/filesystem.js +++ b/src/storage/filesystem.js @@ -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