Fix #334, Fix 331

This commit is contained in:
RobinLinus 2021-08-12 15:38:02 +02:00
parent 5389464605
commit fa1ff95965

View file

@ -186,6 +186,8 @@ class Peer {
} }
_onChunkReceived(chunk) { _onChunkReceived(chunk) {
if(!chunk.byteLength) return;
this._digester.unchunk(chunk); this._digester.unchunk(chunk);
const progress = this._digester.progress; const progress = this._digester.progress;
this._onDownloadProgress(progress); this._onDownloadProgress(progress);
@ -487,6 +489,8 @@ class FileDigester {
this._bytesReceived += chunk.byteLength || chunk.size; this._bytesReceived += chunk.byteLength || chunk.size;
const totalChunks = this._buffer.length; const totalChunks = this._buffer.length;
this.progress = this._bytesReceived / this._size; this.progress = this._bytesReceived / this._size;
if (isNaN(this.progress)) this.progress = 1
if (this._bytesReceived < this._size) return; if (this._bytesReceived < this._size) return;
// we are done // we are done
let blob = new Blob(this._buffer, { type: this._mime }); let blob = new Blob(this._buffer, { type: this._mime });