Fixed exception during file size error and default to Windows style size formatting.

This commit is contained in:
flash 2024-02-02 21:34:17 +00:00
parent 3b2223136e
commit 53bace90e8
2 changed files with 4 additions and 4 deletions

View file

@ -1,12 +1,12 @@
const EEPFMT = (() => {
const symbols = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 'R', 'Q'];
const format = (bytes, binary) => {
const format = (bytes, decimal) => {
if(bytes === 0)
return 'Zero Bytes';
const negative = bytes < 0;
const power = binary ? 1024 : 1000;
const power = decimal ? 1000 : 1024;
const exp = Math.floor(Math.log(bytes) / Math.log(power));
bytes = Math.abs(bytes);
@ -31,7 +31,7 @@ const EEPFMT = (() => {
if(number > 1)
string += 's';
} else {
if(binary)
if(!decimal)
string += 'i';
string += 'B';
}

View file

@ -105,7 +105,7 @@ const EEPROM = function(appId, endPoint, auth) {
toString: () => 'EEPROM app is not configured properly.',
};
if(result.status === 413) {
const maxSize = parseInt(xhr.headers().get('x-eeprom-max-size'));
const maxSize = parseInt(result.headers().get('x-eeprom-max-size'));
const maxSizeFormatted = EEPFMT.format(maxSize);
throw {
error: 'eeprom:size_error',