Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
Fix update function returning a smaller value for totalBytes than wri…
Browse files Browse the repository at this point in the history
…tten (#112)

Co-authored-by: Paulus Schoutsen <[email protected]>
  • Loading branch information
makermelissa and balloob authored Apr 7, 2022
1 parent beda67d commit e93a2a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
2 changes: 1 addition & 1 deletion src/esp_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ export class ESPLoader extends EventTarget {
? Math.round((block.length * uncompressedFilesize) / compressedFilesize)
: block.length;
position += flashWriteSize;
updateProgress(written, filesize);
updateProgress(Math.min(written, filesize), filesize);
}
this.logger.log(
"Took " + (Date.now() - stamp) + "ms to write " + filesize + " bytes"
Expand Down

0 comments on commit e93a2a9

Please sign in to comment.