mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2026-05-13 07:55:01 +00:00
Fix _fileReceived getting called twice
This commit is contained in:
@@ -878,7 +878,7 @@ class Peer {
|
|||||||
this._sendMessage({ type: 'receive-progress', progress: progress });
|
this._sendMessage({ type: 'receive-progress', progress: progress });
|
||||||
}
|
}
|
||||||
|
|
||||||
async _fileReceived(file) {
|
_fileReceived(file) {
|
||||||
// File transfer complete
|
// File transfer complete
|
||||||
this._singleFileReceiveComplete(file);
|
this._singleFileReceiveComplete(file);
|
||||||
|
|
||||||
@@ -912,7 +912,10 @@ class Peer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_singleFileReceiveComplete(file) {
|
_singleFileReceiveComplete(file) {
|
||||||
|
this._digester._fileCompleteCallback = null;
|
||||||
|
this._digester._sendReceiveConfimationCallback = null;
|
||||||
this._digester = null;
|
this._digester = null;
|
||||||
|
|
||||||
this._totalBytesReceived += file.size;
|
this._totalBytesReceived += file.size;
|
||||||
|
|
||||||
const duration = (Date.now() - this._timeStart) / 1000; // s
|
const duration = (Date.now() - this._timeStart) / 1000; // s
|
||||||
@@ -1894,9 +1897,6 @@ class FileDigester {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onPart(part) {
|
function onPart(part) {
|
||||||
// remove old chunk from buffer
|
|
||||||
_this._buffer[i] = null;
|
|
||||||
|
|
||||||
if (i < _this._buffer.length - 1) {
|
if (i < _this._buffer.length - 1) {
|
||||||
// process next chunk
|
// process next chunk
|
||||||
offset += part.byteLength;
|
offset += part.byteLength;
|
||||||
@@ -1925,9 +1925,9 @@ class FileDigester {
|
|||||||
Logger.error(error);
|
Logger.error(error);
|
||||||
Logger.warn('Failed to process file via service-worker. Do not use Firefox private mode to prevent this.')
|
Logger.warn('Failed to process file via service-worker. Do not use Firefox private mode to prevent this.')
|
||||||
|
|
||||||
// Use memory method instead and tidy up.
|
// Use memory method instead and terminate service worker.
|
||||||
_this.processFileViaMemory();
|
|
||||||
fileWorker.terminate();
|
fileWorker.terminate();
|
||||||
|
_this.processFileViaMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendPart(this._buffer[i], offset);
|
sendPart(this._buffer[i], offset);
|
||||||
|
|||||||
Reference in New Issue
Block a user