diff --git a/package.json b/package.json index d11f27e00..e9f51fcde 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ente", "productName": "ente", - "version": "1.5.1", + "version": "1.5.2", "private": true, "description": "Desktop client for ente.io", "main": "app/main.js", diff --git a/src/utils/upload.ts b/src/utils/upload.ts index 012f96405..ab9e231a8 100644 --- a/src/utils/upload.ts +++ b/src/utils/upload.ts @@ -28,21 +28,27 @@ const getFileStream = async (filePath: string) => { let offset = 0; const readableStream = new ReadableStream({ async pull(controller) { - const buff = new Uint8Array(FILE_STREAM_CHUNK_SIZE); + try { + const buff = new Uint8Array(FILE_STREAM_CHUNK_SIZE); - // original types were not working correctly - const bytesRead = (await fs.read( - file, - buff, - 0, - FILE_STREAM_CHUNK_SIZE, - offset - )) as unknown as number; - offset += bytesRead; - if (bytesRead === 0) { - controller.close(); - } else { - controller.enqueue(buff); + // original types were not working correctly + const bytesRead = (await fs.read( + file, + buff, + 0, + FILE_STREAM_CHUNK_SIZE, + offset + )) as unknown as number; + offset += bytesRead; + if (bytesRead === 0) { + controller.close(); + await fs.close(file); + } else { + controller.enqueue(buff); + } + } catch (e) { + logError(e, 'stream pull failed'); + await fs.close(file); } }, });