Fix update returning a smaller value for totalBytes than written

pull/34/head
Melissa LeBlanc-Williams 3 years ago
parent beda67de45
commit 2d8463c2aa

@ -300,9 +300,9 @@ async function clickProgram() {
const progressBar = progress[file].querySelector("div");
await espStub.flashData(
contents,
(bytesWritten) => {
(bytesWritten, totalBytes) => {
progressBar.style.width =
Math.floor((bytesWritten / contents.byteLength) * 100) + "%";
Math.floor((bytesWritten / totalBytes) * 100) + "%";
},
offset
);

@ -618,7 +618,7 @@ export class ESPLoader extends EventTarget {
? Math.round((block.length * uncompressedFilesize) / compressedFilesize)
: block.length;
position += flashWriteSize;
updateProgress(written, filesize);
updateProgress(written, Math.ceil(filesize / flashWriteSize) * flashWriteSize);
}
this.logger.log(
"Took " + (Date.now() - stamp) + "ms to write " + filesize + " bytes"

Loading…
Cancel
Save