🐛 Add error message to getFileFromdisks
This commit is contained in:
parent
099fecce98
commit
86ba51731c
1 changed files with 10 additions and 0 deletions
|
@ -51,9 +51,14 @@ export default function getFileFromDisks(disks: string[], { diskStart, offset, s
|
|||
const onData = (chunk: Buffer) => {
|
||||
outputStream.write(chunk);
|
||||
totalRead += chunk.length;
|
||||
//TODO: need to end if we have read beyond the file
|
||||
if (localFileHeaderLength !== 0 && totalRead >= localFileHeaderLength + storedSize) {
|
||||
//TODO
|
||||
}
|
||||
};
|
||||
const onEnd = () => {
|
||||
curDiskIndex += 1;
|
||||
//End if we are at end of file or end of disks
|
||||
if (curDiskIndex >= disks.length || (localFileHeaderLength !== 0 && totalRead >= localFileHeaderLength + storedSize)) {
|
||||
outputStream.end();
|
||||
} else {
|
||||
|
@ -61,11 +66,16 @@ export default function getFileFromDisks(disks: string[], { diskStart, offset, s
|
|||
//set up new listeners for data and end
|
||||
curDisk.on('data', onData);
|
||||
curDisk.on('end', onEnd);
|
||||
curDisk.on('error', onError);
|
||||
}
|
||||
};
|
||||
const onError = (error: any) => {
|
||||
console.error(error);
|
||||
};
|
||||
|
||||
curDisk.on('data', onData);
|
||||
curDisk.on('end', onEnd);
|
||||
curDisk.on('error', onError);
|
||||
|
||||
//Read local file header
|
||||
localFileHeaderLength = readLocalFileHeader(outputStream);
|
||||
|
|
Loading…
Reference in a new issue