Fixed exception during file size error and default to Windows style size formatting.
This commit is contained in:
parent
3b2223136e
commit
53bace90e8
2 changed files with 4 additions and 4 deletions
|
@ -1,12 +1,12 @@
|
||||||
const EEPFMT = (() => {
|
const EEPFMT = (() => {
|
||||||
const symbols = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 'R', 'Q'];
|
const symbols = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 'R', 'Q'];
|
||||||
|
|
||||||
const format = (bytes, binary) => {
|
const format = (bytes, decimal) => {
|
||||||
if(bytes === 0)
|
if(bytes === 0)
|
||||||
return 'Zero Bytes';
|
return 'Zero Bytes';
|
||||||
|
|
||||||
const negative = bytes < 0;
|
const negative = bytes < 0;
|
||||||
const power = binary ? 1024 : 1000;
|
const power = decimal ? 1000 : 1024;
|
||||||
const exp = Math.floor(Math.log(bytes) / Math.log(power));
|
const exp = Math.floor(Math.log(bytes) / Math.log(power));
|
||||||
|
|
||||||
bytes = Math.abs(bytes);
|
bytes = Math.abs(bytes);
|
||||||
|
@ -31,7 +31,7 @@ const EEPFMT = (() => {
|
||||||
if(number > 1)
|
if(number > 1)
|
||||||
string += 's';
|
string += 's';
|
||||||
} else {
|
} else {
|
||||||
if(binary)
|
if(!decimal)
|
||||||
string += 'i';
|
string += 'i';
|
||||||
string += 'B';
|
string += 'B';
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ const EEPROM = function(appId, endPoint, auth) {
|
||||||
toString: () => 'EEPROM app is not configured properly.',
|
toString: () => 'EEPROM app is not configured properly.',
|
||||||
};
|
};
|
||||||
if(result.status === 413) {
|
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);
|
const maxSizeFormatted = EEPFMT.format(maxSize);
|
||||||
throw {
|
throw {
|
||||||
error: 'eeprom:size_error',
|
error: 'eeprom:size_error',
|
||||||
|
|
Loading…
Reference in a new issue