From e53085e47ce4badea54ce9ee68c75355610fde5a Mon Sep 17 00:00:00 2001 From: Monika Radaviciute Date: Wed, 20 Dec 2023 16:22:39 +0200 Subject: [PATCH 1/2] Fix upload not starting after cancelling large uploads --- .../wasm/js/crypt-post-upworker.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/swift_browser_ui_frontend/wasm/js/crypt-post-upworker.js b/swift_browser_ui_frontend/wasm/js/crypt-post-upworker.js index f5cc59ac6..4098d567a 100644 --- a/swift_browser_ui_frontend/wasm/js/crypt-post-upworker.js +++ b/swift_browser_ui_frontend/wasm/js/crypt-post-upworker.js @@ -298,12 +298,14 @@ class StreamSlicer{ while (uploadCount > 4) { await timeout(250); } - uploadCount++; - postMessage({ - eventType: "activeFile", - object: this.file.name, - }); - await this.sendChunks(); + if (!uploadCancelled) { + uploadCount++; + postMessage({ + eventType: "activeFile", + object: this.file.name, + }); + await this.sendChunks(); + } } finishFile() { From 822b2078c061f88926dd4945029adb4314fe3df2 Mon Sep 17 00:00:00 2001 From: Monika Radaviciute Date: Thu, 21 Dec 2023 17:02:10 +0200 Subject: [PATCH 2/2] Only try to encrypt chunk if upload session exists --- swift_browser_ui_frontend/wasm/js/crypt-post-upworker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/swift_browser_ui_frontend/wasm/js/crypt-post-upworker.js b/swift_browser_ui_frontend/wasm/js/crypt-post-upworker.js index 4098d567a..e58c419a5 100644 --- a/swift_browser_ui_frontend/wasm/js/crypt-post-upworker.js +++ b/swift_browser_ui_frontend/wasm/js/crypt-post-upworker.js @@ -159,6 +159,7 @@ function createUploadSessionFile(container, path) { // Encrypt a single chunk of an upload function encryptChunk(container, path, deChunk) { + if (!uploads[container]) return undefined; let chunk = Module.ccall( "encrypt_chunk", "number", @@ -241,7 +242,7 @@ class StreamSlicer{ } retryChunk(iter) { - this.getChunk(iter).then(async (chunk) => { + this.getChunk(iter).then(async () => { if (uploads[this.container]) { let chunk = await this.getChunk(iter);