From fa1ff959656ead380ed99c9955b9648506538e8c Mon Sep 17 00:00:00 2001 From: RobinLinus Date: Thu, 12 Aug 2021 15:38:02 +0200 Subject: [PATCH] Fix #334, Fix 331 --- client/scripts/network.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/scripts/network.js b/client/scripts/network.js index 592053b..da7e96a 100644 --- a/client/scripts/network.js +++ b/client/scripts/network.js @@ -186,6 +186,8 @@ class Peer { } _onChunkReceived(chunk) { + if(!chunk.byteLength) return; + this._digester.unchunk(chunk); const progress = this._digester.progress; this._onDownloadProgress(progress); @@ -487,6 +489,8 @@ class FileDigester { this._bytesReceived += chunk.byteLength || chunk.size; const totalChunks = this._buffer.length; this.progress = this._bytesReceived / this._size; + if (isNaN(this.progress)) this.progress = 1 + if (this._bytesReceived < this._size) return; // we are done let blob = new Blob(this._buffer, { type: this._mime });