From 23e392107294437cded6b9641e25bd31d3532a8d Mon Sep 17 00:00:00 2001 From: codedread Date: Fri, 26 Jan 2018 00:12:58 -0800 Subject: [PATCH] Track number of compressed bytes read in while unarchiving and reporting progress --- archive/archive.js | 5 ++++- archive/unrar.js | 4 +++- archive/untar.js | 4 +++- archive/unzip.js | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/archive/archive.js b/archive/archive.js index be6877a..9de9a42 100644 --- a/archive/archive.js +++ b/archive/archive.js @@ -104,9 +104,11 @@ bitjs.archive.UnarchiveProgressEvent = class extends bitjs.archive.UnarchiveEven * @param {number} currentBytesUnarchived * @param {number} totalUncompressedBytesInArchive * @param {number} totalFilesInArchive + * @param {number} totalCompressedBytesRead */ constructor(currentFilename, currentFileNumber, currentBytesUnarchivedInFile, - currentBytesUnarchived, totalUncompressedBytesInArchive, totalFilesInArchive) { + currentBytesUnarchived, totalUncompressedBytesInArchive, totalFilesInArchive, + totalCompressedBytesRead) { super(bitjs.archive.UnarchiveEvent.Type.PROGRESS); this.currentFilename = currentFilename; @@ -115,6 +117,7 @@ bitjs.archive.UnarchiveProgressEvent = class extends bitjs.archive.UnarchiveEven this.totalFilesInArchive = totalFilesInArchive; this.currentBytesUnarchived = currentBytesUnarchived; this.totalUncompressedBytesInArchive = totalUncompressedBytesInArchive; + this.totalCompressedBytesRead = totalCompressedBytesRead; } } diff --git a/archive/unrar.js b/archive/unrar.js index 9f38986..bfe4c16 100644 --- a/archive/unrar.js +++ b/archive/unrar.js @@ -47,7 +47,9 @@ const postProgress = function() { currentBytesUnarchivedInFile, currentBytesUnarchived, totalUncompressedBytesInArchive, - totalFilesInArchive)); + totalFilesInArchive, + parseInt(bitstream.getNumBitsRead() / 8, 10), + )); }; // shows a byte value as its hex representation diff --git a/archive/untar.js b/archive/untar.js index 08da6ed..523476a 100644 --- a/archive/untar.js +++ b/archive/untar.js @@ -48,7 +48,9 @@ const postProgress = function() { currentBytesUnarchivedInFile, currentBytesUnarchived, totalUncompressedBytesInArchive, - totalFilesInArchive)); + totalFilesInArchive, + bytestream.getNumBytesRead(), + )); }; // Removes all characters from the first zero-byte in the string onwards. diff --git a/archive/unzip.js b/archive/unzip.js index debb956..927f17b 100644 --- a/archive/unzip.js +++ b/archive/unzip.js @@ -52,7 +52,9 @@ const postProgress = function() { currentBytesUnarchivedInFile, currentBytesUnarchived, totalUncompressedBytesInArchive, - totalFilesInArchive)); + totalFilesInArchive, + bytestream.getNumBytesRead(), + )); }; const zLocalFileHeaderSignature = 0x04034b50;