mirror of https://github.com/coder/code-server.git
Fix human readable byte size when zero
This commit is contained in:
parent
0462a93f11
commit
4a29cd1664
|
@ -505,9 +505,8 @@ class DialogEntryRenderer implements ITreeRenderer<DialogEntry, string, DialogEn
|
||||||
*/
|
*/
|
||||||
private humanReadableSize(bytes: number): string {
|
private humanReadableSize(bytes: number): string {
|
||||||
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||||
const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1000)), units.length - 1);
|
const i = Math.min(Math.floor(bytes && Math.log(bytes) / Math.log(1000)), units.length - 1);
|
||||||
|
|
||||||
return (bytes / Math.pow(1000, i)).toFixed(2)
|
return (bytes / Math.pow(1000, i)).toFixed(2) + " " + units[i];
|
||||||
+ " " + units[i];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue