🐛 Found error why .read() returns null; need to wait for readable event

This commit is contained in:
C-3PO 2018-07-05 21:17:07 +02:00
parent 6d6c673556
commit 89d1b9e644
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
2 changed files with 2 additions and 1 deletions

View file

@ -58,7 +58,7 @@ export default function saveResponse(
//TODO: need to automatically delete file once it is no longer used //TODO: need to automatically delete file once it is no longer used
//TODO: need to provide methods to seek through file //TODO: need to provide methods to seek through file
return resolve(tempFileName); return resolve(tempFileName);
//const stream = fs.createReadStream(tempFileName, { encoding: 'binary' }); //TODO: we may need to remove encoding since mentioning encoding automatically switches to string format //const stream = fs.createReadStream(tempFileName);
//return resolve(stream); //return resolve(stream);
}); });
} }

View file

@ -28,6 +28,7 @@ export default function getFileFromDisks(disks: string[], { diskStart, offset, s
if (chunk === null) { if (chunk === null) {
curDiskIndex += 1; curDiskIndex += 1;
curDisk = getStream(disks, curDiskIndex, 0); curDisk = getStream(disks, curDiskIndex, 0);
//await new Promise((resolve) => { curDisk.on('readable', () => { resolve(); }); });
return curDisk.read(num); return curDisk.read(num);
} else { } else {
return chunk; return chunk;