From 2488ffb403f6e176acf3a718e07359a35a3dbe28 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 9 Jun 2021 13:48:32 -0700 Subject: [PATCH] Fix write percentage progress --- src/start-flash.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/start-flash.ts b/src/start-flash.ts index 6e9dd57..2e48786 100644 --- a/src/start-flash.ts +++ b/src/start-flash.ts @@ -145,11 +145,14 @@ export const startFlash = async ( content: html`Writing progress: ${lastPct}%`, }); + let totalWritten = 0; + for (const part of build.parts) { await espStub.flashData( files.shift()!, (newBytesWritten) => { - const newPct = Math.floor((newBytesWritten / totalSize) * 100); + totalWritten += newBytesWritten; + const newPct = Math.floor((totalWritten / totalSize) * 100); if (newPct === lastPct) { return; }