@zip.js/zip.js 2.6.21 → 2.6.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/io.js +2 -2
- package/lib/core/zip-writer.js +9 -9
- package/package.json +1 -1
- package/tests/all/test-zip64-auto.js +11 -5
package/lib/core/io.js
CHANGED
|
@@ -226,7 +226,7 @@ class BlobWriter extends Stream {
|
|
|
226
226
|
const writer = this;
|
|
227
227
|
writer.contentType = contentType;
|
|
228
228
|
writer.transformStream = new TransformStream();
|
|
229
|
-
Object.defineProperty(
|
|
229
|
+
Object.defineProperty(writer, "writable", {
|
|
230
230
|
get() {
|
|
231
231
|
return writer.transformStream.writable;
|
|
232
232
|
}
|
|
@@ -240,7 +240,7 @@ class BlobWriter extends Stream {
|
|
|
240
240
|
transformStream,
|
|
241
241
|
contentType
|
|
242
242
|
} = writer;
|
|
243
|
-
writer.blob = new Response(transformStream.readable
|
|
243
|
+
writer.blob = new Response(transformStream.readable, { headers: [["content-type", contentType]] }).blob();
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
getData() {
|
package/lib/core/zip-writer.js
CHANGED
|
@@ -298,11 +298,11 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
298
298
|
externalFileAttribute,
|
|
299
299
|
useCompressionStream
|
|
300
300
|
});
|
|
301
|
-
const
|
|
301
|
+
const headerInfo = getHeaderInfo(options);
|
|
302
302
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
303
|
-
maximumEntrySize =
|
|
303
|
+
maximumEntrySize = headerInfo.localHeaderArray.length + maximumCompressedSize + dataDescriptorInfo.dataDescriptorArray.length;
|
|
304
304
|
zipWriter.pendingEntriesSize += maximumEntrySize;
|
|
305
|
-
const fileEntry = await getFileEntry(zipWriter, name, reader, {
|
|
305
|
+
const fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo }, options);
|
|
306
306
|
if (maximumEntrySize) {
|
|
307
307
|
zipWriter.pendingEntriesSize -= maximumEntrySize;
|
|
308
308
|
}
|
|
@@ -428,7 +428,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
428
428
|
|
|
429
429
|
async function createFileEntry(reader, writer, pendingFileEntry, entryInfo, config, options) {
|
|
430
430
|
const {
|
|
431
|
-
|
|
431
|
+
headerInfo,
|
|
432
432
|
dataDescriptorInfo
|
|
433
433
|
} = entryInfo;
|
|
434
434
|
const {
|
|
@@ -443,7 +443,7 @@ async function createFileEntry(reader, writer, pendingFileEntry, entryInfo, conf
|
|
|
443
443
|
rawExtraFieldExtendedTimestamp,
|
|
444
444
|
rawExtraFieldNTFS,
|
|
445
445
|
rawExtraFieldAES
|
|
446
|
-
} =
|
|
446
|
+
} = headerInfo;
|
|
447
447
|
const { dataDescriptorArray } = dataDescriptorInfo;
|
|
448
448
|
const {
|
|
449
449
|
rawFilename,
|
|
@@ -530,7 +530,7 @@ async function createFileEntry(reader, writer, pendingFileEntry, entryInfo, conf
|
|
|
530
530
|
rawExtraFieldZip64,
|
|
531
531
|
compressedSize,
|
|
532
532
|
uncompressedSize,
|
|
533
|
-
|
|
533
|
+
headerInfo,
|
|
534
534
|
dataDescriptorInfo
|
|
535
535
|
}, options);
|
|
536
536
|
}
|
|
@@ -554,7 +554,7 @@ async function createFileEntry(reader, writer, pendingFileEntry, entryInfo, conf
|
|
|
554
554
|
return fileEntry;
|
|
555
555
|
}
|
|
556
556
|
|
|
557
|
-
function
|
|
557
|
+
function getHeaderInfo(options) {
|
|
558
558
|
const {
|
|
559
559
|
rawFilename,
|
|
560
560
|
lastAccessDate,
|
|
@@ -712,13 +712,13 @@ function setEntryInfo(entryInfo, options) {
|
|
|
712
712
|
rawExtraFieldZip64,
|
|
713
713
|
compressedSize,
|
|
714
714
|
uncompressedSize,
|
|
715
|
-
|
|
715
|
+
headerInfo,
|
|
716
716
|
dataDescriptorInfo
|
|
717
717
|
} = entryInfo;
|
|
718
718
|
const {
|
|
719
719
|
headerView,
|
|
720
720
|
encrypted
|
|
721
|
-
} =
|
|
721
|
+
} = headerInfo;
|
|
722
722
|
const {
|
|
723
723
|
dataDescriptorView,
|
|
724
724
|
dataDescriptorOffset
|
package/package.json
CHANGED
|
@@ -53,20 +53,26 @@ async function test() {
|
|
|
53
53
|
zip.configure({ chunkSize: 128, useWebWorkers: true });
|
|
54
54
|
const blobWriter = new CustomBlobWriter("application/zip");
|
|
55
55
|
blobWriter.writable.size = 0;
|
|
56
|
-
|
|
57
|
-
for (let index = 0; index <
|
|
56
|
+
let array = new Uint8Array(64 * 1024 * 1024);
|
|
57
|
+
for (let index = 0; index < 63; index++) {
|
|
58
58
|
blobWriter.writeUint8Array(array);
|
|
59
59
|
blobWriter.writable.size += array.length;
|
|
60
60
|
}
|
|
61
|
+
array = new Uint8Array((64 * 1024 * 1024) - 1265);
|
|
62
|
+
blobWriter.writeUint8Array(array);
|
|
63
|
+
blobWriter.writable.size += array.length;
|
|
61
64
|
const zipWriter = new zip.ZipWriter(blobWriter, { keepOrder: true });
|
|
62
|
-
await
|
|
65
|
+
await Promise.all([
|
|
66
|
+
zipWriter.add(FILENAME, new zip.BlobReader(BLOB)),
|
|
67
|
+
zipWriter.add(FILENAME + "1", new zip.BlobReader(BLOB)),
|
|
68
|
+
zipWriter.add(FILENAME + "2", new zip.BlobReader(BLOB))
|
|
69
|
+
]);
|
|
63
70
|
await zipWriter.close();
|
|
64
71
|
const zipReader = new zip.ZipReader(new zip.BlobReader(await blobWriter.getData()));
|
|
65
72
|
const entries = await zipReader.getEntries();
|
|
66
|
-
const data = await entries[0].getData(new zip.BlobWriter(zip.getMimeType(entries[0].filename)));
|
|
67
73
|
await zipReader.close();
|
|
68
74
|
zip.terminateWorkers();
|
|
69
|
-
if (
|
|
75
|
+
if (entries[0].zip64 || entries[1].zip64 || !entries[2].zip64) {
|
|
70
76
|
throw new Error();
|
|
71
77
|
}
|
|
72
78
|
}
|