Skip to content

Commit 456a7fd

Browse files
author
Hang Le
committed
Skip: Fix premature encrypted download termination (merge commit)
Merge branch 'bugfix/fix-premature-encrypted-download-termination' into 'main' * add linter changes in downworker * fix download status not updating for encrypted downloads * fix undefined header breaking encrypted downloads See merge request https://gitlab.ci.csc.fi/sds-dev/sd-connect/swift-browser-ui/-/merge_requests/331 Approved-by: Hang Le <[email protected]> Co-authored-by: Sampsa Penna <[email protected]> Merged by Hang Le <[email protected]>
2 parents 352c9de + 78c979c commit 456a7fd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

swift_browser_ui_frontend/wasm/js/crypt-post-downworker.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,12 @@ class FileSlicer {
287287
async concatFile() {
288288
// If the file can't be decrypted, add the header and concat the encrypted
289289
// file to the stream
290-
if (this.output instanceof WritableStream) {
291-
await this.output.write(downloads[this.id].files[this.path].header);
292-
} else {
293-
this.output.enqueue(downloads[this.id].files[this.path].header);
290+
if (downloads[this.id].files[this.path].header.length > 0) {
291+
if (this.output instanceof WritableStream) {
292+
await this.output.write(downloads[this.id].files[this.path].header);
293+
} else {
294+
this.output.enqueue(downloads[this.id].files[this.path].header);
295+
}
294296
}
295297

296298
await this.getStart();
@@ -306,6 +308,7 @@ class FileSlicer {
306308
this.output.enqueue(new Uint8Array(this.chunk));
307309
}
308310
this.totalBytes += this.chunk.length;
311+
totalDone += this.chunk.length;
309312
({ value: this.chunk, done: this.done } = await this.reader.read());
310313

311314
if (this.done && this.segmentOffset < downloads[this.id].files[this.path].realsize) {

0 commit comments

Comments
 (0)