diff --git a/desktop/src/services/fs.ts b/desktop/src/services/fs.ts index c74790d01..356b49c18 100644 --- a/desktop/src/services/fs.ts +++ b/desktop/src/services/fs.ts @@ -25,16 +25,14 @@ export const getDirFilePaths = async (dirPath: string) => { return files; }; -export const getFileStream = async (filePath: string) => { +const getFileStream = async (filePath: string) => { const file = await fs.open(filePath, "r"); let offset = 0; const readableStream = new ReadableStream({ async pull(controller) { try { const buff = new Uint8Array(FILE_STREAM_CHUNK_SIZE); - // original types were not working correctly - const bytesRead = (await fs.read( - file, + const bytesRead = (await file.read( buff, 0, FILE_STREAM_CHUNK_SIZE, @@ -43,16 +41,16 @@ export const getFileStream = async (filePath: string) => { offset += bytesRead; if (bytesRead === 0) { controller.close(); - await fs.close(file); + await file.close(); } else { controller.enqueue(buff.slice(0, bytesRead)); } } catch (e) { - await fs.close(file); + await file.close(); } }, async cancel() { - await fs.close(file); + await file.close(); }, }); return readableStream;