🚧 Change streamToArraybuffer to return Buffer for better debuggin
This commit is contained in:
parent
695ee74e72
commit
7b5cdd5498
2 changed files with 4 additions and 4 deletions
|
@ -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) => {
|
fileEntries.filter((file) => file.diffType === SsnDiffType.NewFile).forEach(async (file) => {
|
||||||
try {
|
try {
|
||||||
const fileStream = await getFileFromDisks(diskFilenames, { diskStart: file.diskNumberStart, offset: file.offset, length: file.compressedSize });
|
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));
|
console.debug(file.name, file.compressedSize, await streamToArrayBuffer(fileContents));
|
||||||
//TODO: need to write to disk
|
//TODO: need to write to disk
|
||||||
} catch (error) {
|
} 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) => {
|
fileEntries.filter((file) => file.diffType === SsnDiffType.Changed).forEach(async (file) => {
|
||||||
try {
|
try {
|
||||||
const fileStream = await getFileFromDisks(diskFilenames, { diskStart: file.diskNumberStart, offset: file.offset, length: file.compressedSize });
|
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));
|
console.debug(file.name, file.compressedSize, await streamToArrayBuffer(fileContents));
|
||||||
//TODO: need to apply diffing, then write to disk
|
//TODO: need to apply diffing, then write to disk
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as stream from 'stream';
|
import * as stream from 'stream';
|
||||||
|
|
||||||
export default function streamToArrayBuffer(inputStream: stream.Readable): Promise<ArrayBuffer> {
|
export default function streamToArrayBuffer(inputStream: stream.Readable): Promise<Buffer> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const chunks: Buffer[] = [];
|
const chunks: Buffer[] = [];
|
||||||
let totalSize = 0;
|
let totalSize = 0;
|
||||||
|
@ -14,7 +14,7 @@ export default function streamToArrayBuffer(inputStream: stream.Readable): Promi
|
||||||
//Output final string
|
//Output final string
|
||||||
inputStream.on('end', () => {
|
inputStream.on('end', () => {
|
||||||
const outBuffer = Buffer.concat(chunks, totalSize);
|
const outBuffer = Buffer.concat(chunks, totalSize);
|
||||||
resolve(outBuffer.buffer as ArrayBuffer);
|
resolve(outBuffer);
|
||||||
});
|
});
|
||||||
|
|
||||||
//Exit on error
|
//Exit on error
|
||||||
|
|
Loading…
Reference in a new issue