From 7b5cdd5498e101aa7c2998d97e59686ab8e0ce30 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Sun, 8 Jul 2018 20:26:17 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Change=20streamToArraybuffer=20t?= =?UTF-8?q?o=20return=20Buffer=20for=20better=20debuggin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssn/getPatch.ts | 4 ++-- src/ssn/streams/streamToArrayBuffer.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ssn/getPatch.ts b/src/ssn/getPatch.ts index 1eaf42c..78595ab 100644 --- a/src/ssn/getPatch.ts +++ b/src/ssn/getPatch.ts @@ -40,7 +40,7 @@ export default async function getPatch(product: Product, from: number, to: numbe fileEntries.filter((file) => file.diffType === SsnDiffType.NewFile).forEach(async (file) => { try { const fileStream = await getFileFromDisks(diskFilenames, { diskStart: file.diskNumberStart, offset: file.offset, length: file.compressedSize }); - const fileContents = extractFileStream(file, fileStream); + const fileContents = extractFileStream(file, fileStream, true); console.debug(file.name, file.compressedSize, await streamToArrayBuffer(fileContents)); //TODO: need to write to disk } catch (error) { @@ -52,7 +52,7 @@ export default async function getPatch(product: Product, from: number, to: numbe fileEntries.filter((file) => file.diffType === SsnDiffType.Changed).forEach(async (file) => { try { const fileStream = await getFileFromDisks(diskFilenames, { diskStart: file.diskNumberStart, offset: file.offset, length: file.compressedSize }); - const fileContents = extractFileStream(file, fileStream); + const fileContents = extractFileStream(file, fileStream, true); console.debug(file.name, file.compressedSize, await streamToArrayBuffer(fileContents)); //TODO: need to apply diffing, then write to disk } catch (error) { diff --git a/src/ssn/streams/streamToArrayBuffer.ts b/src/ssn/streams/streamToArrayBuffer.ts index 8589655..ec7d694 100644 --- a/src/ssn/streams/streamToArrayBuffer.ts +++ b/src/ssn/streams/streamToArrayBuffer.ts @@ -1,6 +1,6 @@ import * as stream from 'stream'; -export default function streamToArrayBuffer(inputStream: stream.Readable): Promise { +export default function streamToArrayBuffer(inputStream: stream.Readable): Promise { return new Promise((resolve, reject) => { const chunks: Buffer[] = []; let totalSize = 0; @@ -14,7 +14,7 @@ export default function streamToArrayBuffer(inputStream: stream.Readable): Promi //Output final string inputStream.on('end', () => { const outBuffer = Buffer.concat(chunks, totalSize); - resolve(outBuffer.buffer as ArrayBuffer); + resolve(outBuffer); }); //Exit on error