MCPcopy Create free account
hub / github.com/hoothin/UserScripts / checkEntryCRC32

Function checkEntryCRC32

Picviewer CE+/dist.user.js:1349–1364  ·  view source on GitHub ↗

* Check the CRC32 of an entry. * @param {ZipEntry} zipEntry the zip entry to check. * @return {Promise} the result.

(zipEntry)

Source from the content-addressed store, hash-verified

1347 * @return {Promise} the result.
1348 */
1349function checkEntryCRC32(zipEntry) {
1350 return new external.Promise(function (resolve, reject) {
1351 var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());
1352 worker.on("error", function (e) {
1353 reject(e);
1354 })
1355 .on("end", function () {
1356 if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {
1357 reject(new Error("Corrupted zip : CRC32 mismatch"));
1358 } else {
1359 resolve();
1360 }
1361 })
1362 .resume();
1363 });
1364}
1365
1366module.exports = function (data, options) {
1367 var zip = this;

Callers 1

dist.user.jsFile · 0.70

Calls 2

rejectFunction · 0.70
resolveFunction · 0.70

Tested by

no test coverage detected