1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-16 12:55:14 +03:00

Fix and make bigger max size local file to flash

This commit is contained in:
Miguel Angel Mulero Martinez 2019-07-02 16:28:51 +02:00
parent a113a6b97a
commit e38afdcf46
2 changed files with 15 additions and 5 deletions

View file

@ -379,17 +379,24 @@ TABS.firmware_flasher.initialize = function (callback) {
analytics.setFirmwareData(analytics.DATA.FIRMWARE_NAME, file.name);
var reader = new FileReader();
// Max size in bytes of the local file to load and flash
const MAX_FLASH_LOCAL_FILE_SIZE = 2*1024*1024;
reader.onprogress = function (e) {
if (e.total > 1048576) { // 1 MB
// dont allow reading files bigger then 1 MB
console.log('File limit (1 MB) exceeded, aborting');
if (e.total > MAX_FLASH_LOCAL_FILE_SIZE) {
reader.abort();
}
};
reader.onloadend = function(e) {
if (e.total != 0 && e.total == e.loaded) {
console.log('File loaded');
if (e.total > MAX_FLASH_LOCAL_FILE_SIZE) {
console.log('File limit (' + MAX_FLASH_LOCAL_FILE_SIZE + ') exceeded, aborting');
$('span.progressLabel').text(i18n.getMessage('firmwareFlasherTooBig', e.total));
} else if (e.total != 0 && e.total == e.loaded) {
console.log('File loaded (' + e.loaded + ')');
intel_hex = e.target.result;