From 755aba54bd73fbc5e08e48e30f7316f6b40e48fd Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Sun, 12 Dec 2021 12:58:34 -0800 Subject: [PATCH] Make buffers transferable out of the Worker for unrar/untar too --- archive/unrar.js | 3 ++- archive/untar.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/archive/unrar.js b/archive/unrar.js index 19c3388..28a2659 100644 --- a/archive/unrar.js +++ b/archive/unrar.js @@ -1302,6 +1302,7 @@ class RarLocalFile { } else { // read in the compressed data + /** @type {Uint8Array} */ this.fileData = null; if (this.header.packSize > 0) { this.fileData = bstream.readBytes(this.header.packSize); @@ -1377,7 +1378,7 @@ function unrar() { localFile.unrar(); if (localFile.isValid) { - postMessage({ type: 'extract', unarchivedFile: localFile }); + postMessage({ type: 'extract', unarchivedFile: localFile }, [localFile.fileData.buffer]); postProgress(); } } else if (localFile.header.packSize == 0 && localFile.header.unpackedSize == 0) { diff --git a/archive/untar.js b/archive/untar.js index 76d94be..ed63a47 100644 --- a/archive/untar.js +++ b/archive/untar.js @@ -100,6 +100,7 @@ class TarLocalFile { // Done header, now rest of blocks are the file contents. this.filename = this.name; + /** @type {Uint8Array} */ this.fileData = null; info("Untarring file '" + this.filename + "'"); @@ -146,7 +147,7 @@ const untar = function () { currentFileNumber = totalFilesInArchive++; currentBytesUnarchivedInFile = oneLocalFile.size; currentBytesUnarchived += oneLocalFile.size; - postMessage({ type: 'extract', unarchivedFile: oneLocalFile }); + postMessage({ type: 'extract', unarchivedFile: oneLocalFile }, [oneLocalFile.fileData.buffer]); postProgress(); } }