🎨 Improve error output

This commit is contained in:
C-3PO 2018-07-08 18:33:53 +02:00
parent 6f6f168192
commit 662c2d5f43
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
2 changed files with 17 additions and 9 deletions

View file

@ -38,18 +38,26 @@ export default async function getPatch(product: Product, from: number, to: numbe
//Extract newly added files
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);
console.debug(await streamToArrayBuffer(fileContents));
//TODO: need to write to disk
} catch (error) {
console.error(`Could not extract file "${file.name}"`, error);
}
});
//Extract changed files
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);
console.debug(await streamToArrayBuffer(fileContents));
//TODO: need to apply diffing, then write to disk
} catch (error) {
console.error(`Could not extract file "${file.name}"`, error);
}
});
//Need to delete deleted files

View file

@ -12,7 +12,7 @@ interface IGetFileFromDisksOptions {
}
function getStream(disks: string[], index: number, offset: number, length: number = Infinity) {
return fs.createReadStream(disks[index], { start: offset }); //, end: offset + length - 1 });
return fs.createReadStream(disks[index], { start: offset });
}
/** Takes a list of ReadableStreams (the disks), as well as the offset and length, and returns a stream for just one file. */