1
0
Fork 0
mirror of https://github.com/codedread/bitjs synced 2025-10-03 17:49:16 +02:00

Surface metadata from zip files to clients

This commit is contained in:
codedread 2020-01-19 09:33:58 -08:00
parent 2916cf0926
commit 58ac1aed25
2 changed files with 12 additions and 5 deletions

View file

@ -574,7 +574,6 @@ function unzip() {
}
// read all file headers
// TODO: This structure tells us the intended order of the files in the zip.
while (bstream.peekNumber(4) == zCentralFileHeaderSignature) {
bstream.readNumber(4); // signature
const cdfh = {
@ -618,6 +617,7 @@ function unzip() {
bstream.readString(sizeOfSignature); // digital signature data
}
let metadata = {};
if (bstream.peekNumber(4) == zEndOfCentralDirSignature) {
bstream.readNumber(4); // signature
const eocds = {
@ -636,11 +636,15 @@ function unzip() {
console.log(` ${field} = ${eocds[field]}`);
}
}
metadata.comment = eocds.comment;
}
postProgress();
bytestream = bstream.tee();
unarchiveState = UnarchiveState.FINISHED;
postMessage(new bitjs.archive.UnarchiveFinishEvent(metadata));
}
// event.data.file has the first ArrayBuffer.
@ -677,8 +681,6 @@ onmessage = function(event) {
unarchiveState === UnarchiveState.WAITING) {
try {
unzip();
unarchiveState = UnarchiveState.FINISHED;
postMessage(new bitjs.archive.UnarchiveFinishEvent());
} catch (e) {
if (typeof e === 'string' && e.startsWith('Error! Overflowed')) {
// Overrun the buffer.