🚧 Only skip decompression for disks
This commit is contained in:
parent
4e41a46006
commit
a6de035101
2 changed files with 12 additions and 10 deletions
|
@ -10,7 +10,7 @@ import streamSetMaxLength from './streams/streamSetMaxLength';
|
|||
* The stream must already start at the .zip's local file header
|
||||
* and must transparently span across multiple disks if necessary.
|
||||
*/
|
||||
export default function extractFileStream(file: ISsnFileEntry, inputStream: stream.Readable): stream.Readable {
|
||||
export default function extractFileStream(file: ISsnFileEntry, inputStream: stream.Readable, skipDecompression: boolean = false): stream.Readable {
|
||||
let curStream = inputStream;
|
||||
|
||||
curStream = streamSetMaxLength(curStream, file.compressedSize);
|
||||
|
@ -21,13 +21,15 @@ export default function extractFileStream(file: ISsnFileEntry, inputStream: stre
|
|||
curStream = curStream.pipe(decryptTransform);
|
||||
}
|
||||
|
||||
/*//pipe into decompression
|
||||
if (skipDecompression) {
|
||||
//pipe into decompression
|
||||
const decompressTransform = zlib.createInflateRaw();
|
||||
decompressTransform.on('error', (error) => {
|
||||
//TODO: need to throw error sync, not async
|
||||
throw new Error(`Error during decompression of "${file.name}": ${error.message}`);
|
||||
});
|
||||
curStream = curStream.pipe(decompressTransform);*/
|
||||
curStream = curStream.pipe(decompressTransform);
|
||||
}
|
||||
|
||||
return curStream;
|
||||
}
|
||||
|
|
|
@ -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, storedSize: file.compressedSize });
|
||||
const fileContents = extractFileStream(file, fileStream);
|
||||
const fileContents = extractFileStream(file, fileStream, true);
|
||||
console.debug(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, storedSize: file.compressedSize });
|
||||
const fileContents = extractFileStream(file, fileStream);
|
||||
const fileContents = extractFileStream(file, fileStream, true);
|
||||
console.debug(await streamToArrayBuffer(fileContents));
|
||||
//TODO: need to apply diffing, then write to disk
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in a new issue