🎨 Add debug output to trace zlib error

This commit is contained in:
C-3PO 2018-06-24 01:37:10 +02:00
parent beb2d351da
commit 590dc39f84
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
3 changed files with 3 additions and 2 deletions

View file

@ -10,7 +10,7 @@ interface ISolidFileInfo {
files: ISolidFile[]; files: ISolidFile[];
/** Length of one piece in bytes, e.g. 65536 for 64 KiB, and 4194304 for 4 MiB. */ /** Length of one piece in bytes, e.g. 65536 for 64 KiB, and 4194304 for 4 MiB. */
'piece length': 65536 | 4194304; 'piece length': 65536 | 4194304;
/** Concatenated hashes of all pieces. */ /** Concatenated SHA1 hashes of all pieces, where each hash is 20 bytes long. */
pieces: string; pieces: string;
/** Whether the torrent is private, always 0. */ /** Whether the torrent is private, always 0. */
private: 0 | 1; private: 0 | 1;

View file

@ -31,6 +31,7 @@ export default async function extractFile(file: ISsnFileEntry, dvArray: DataView
//Uncompress file //Uncompress file
const uncompressedBuffer: Buffer = await new Promise((resolve, reject) => { const uncompressedBuffer: Buffer = await new Promise((resolve, reject) => {
console.log(new Uint8Array(dvFinal.buffer));
zlib.inflateRaw(dvFinal, (error, result) => { zlib.inflateRaw(dvFinal, (error, result) => {
if (error !== null) { if (error !== null) {
return reject(error); return reject(error);

View file

@ -1,6 +1,6 @@
import ISolid from '../interfaces/ISolidFile'; import ISolid from '../interfaces/ISolidFile';
/** Verifies metafile.solid for correctness. */ /** Verifies metafile.solid for correctness. See specification at <http://www.bittorrent.org/beps/bep_0003.html>. */
export default function verifySolidpkg(file: ISolid, { product, from, to }: {product: string, from: number, to: number}) { export default function verifySolidpkg(file: ISolid, { product, from, to }: {product: string, from: number, to: number}) {
if (typeof file['creation date'] !== 'number') { if (typeof file['creation date'] !== 'number') {
throw new Error(`Expected creation date to be a number but it was "${file['creation date']}".`); throw new Error(`Expected creation date to be a number but it was "${file['creation date']}".`);