🐛 Fix reading of local file header
This commit is contained in:
parent
e84e5bd3d7
commit
74b312953d
3 changed files with 7 additions and 2 deletions
|
@ -30,7 +30,7 @@ interface ISsnFileEntry {
|
|||
decryptionKeys: [number, number, number] | undefined;
|
||||
/** Number of the disk where the file is stored (0=.z01, 1=.z02 etc.) */
|
||||
diskNumberStart: number;
|
||||
/** Offset */
|
||||
/** Offset into the disk to where the local file header starts. */
|
||||
offset: number;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 });
|
||||
return fs.createReadStream(disks[index], { start: offset, end: offset + length - 1 });
|
||||
}
|
||||
|
||||
/** Takes a list of ReadableStreams (the disks), as well as the offset and length, and returns a stream for just one file. */
|
||||
|
|
|
@ -39,7 +39,12 @@ export default async function readLocalFileHeader(inputStream: stream.Readable):
|
|||
const additionalLength = localFilenameSize + localExtraSize;
|
||||
if (additionalLength > 0) {
|
||||
await waitReadableLength(inputStream, additionalLength);
|
||||
const tmpChunk = inputStream.read(additionalLength);
|
||||
if (tmpChunk === null) {
|
||||
//need to wait until data is ready for reading
|
||||
await waitReadableLength(inputStream, additionalLength);
|
||||
inputStream.read(additionalLength);
|
||||
}
|
||||
}
|
||||
|
||||
return 30 + additionalLength;
|
||||
|
|
Loading…
Reference in a new issue