1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

All: Fixed reading file by chuncks

This commit is contained in:
Laurent Cozic 2017-12-23 21:21:11 +01:00
parent 1891eb4998
commit d13c2cf8d7

View File

@ -46,8 +46,9 @@ class FsDriverNode {
async readFileChunk(handle, length, encoding = 'base64') {
let buffer = new Buffer(length);
const result = await fs.read(handle, buffer, 0, length, null)
const result = await fs.read(handle, buffer, 0, length, null);
if (!result.bytesRead) return null;
buffer = buffer.slice(0, result.bytesRead);
if (encoding === 'base64') return buffer.toString('base64');
if (encoding === 'ascii') return buffer.toString('ascii');
throw new Error('Unsupported encoding: ' + encoding);