소스 검색

Fix type errors in fs.ts

Manav Rathi 1 년 전
부모
커밋
0fdb2fb357
1개의 변경된 파일5개의 추가작업 그리고 7개의 파일을 삭제
  1. 5 7
      desktop/src/services/fs.ts

+ 5 - 7
desktop/src/services/fs.ts

@@ -25,16 +25,14 @@ export const getDirFilePaths = async (dirPath: string) => {
     return files;
     return files;
 };
 };
 
 
-export const getFileStream = async (filePath: string) => {
+const getFileStream = async (filePath: string) => {
     const file = await fs.open(filePath, "r");
     const file = await fs.open(filePath, "r");
     let offset = 0;
     let offset = 0;
     const readableStream = new ReadableStream<Uint8Array>({
     const readableStream = new ReadableStream<Uint8Array>({
         async pull(controller) {
         async pull(controller) {
             try {
             try {
                 const buff = new Uint8Array(FILE_STREAM_CHUNK_SIZE);
                 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,
                     buff,
                     0,
                     0,
                     FILE_STREAM_CHUNK_SIZE,
                     FILE_STREAM_CHUNK_SIZE,
@@ -43,16 +41,16 @@ export const getFileStream = async (filePath: string) => {
                 offset += bytesRead;
                 offset += bytesRead;
                 if (bytesRead === 0) {
                 if (bytesRead === 0) {
                     controller.close();
                     controller.close();
-                    await fs.close(file);
+                    await file.close();
                 } else {
                 } else {
                     controller.enqueue(buff.slice(0, bytesRead));
                     controller.enqueue(buff.slice(0, bytesRead));
                 }
                 }
             } catch (e) {
             } catch (e) {
-                await fs.close(file);
+                await file.close();
             }
             }
         },
         },
         async cancel() {
         async cancel() {
-            await fs.close(file);
+            await file.close();
         },
         },
     });
     });
     return readableStream;
     return readableStream;