瀏覽代碼

fix(files): add debug logs for checking chunks upon finishing upload session

Karol Sójko 2 年之前
父節點
當前提交
5f0929c1aa
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      packages/files/src/Infra/FS/FSFileUploader.ts

+ 7 - 1
packages/files/src/Infra/FS/FSFileUploader.ts

@@ -60,7 +60,13 @@ export class FSFileUploader implements FileUploaderInterface {
 
     const orderedKeys = [...fileChunks.keys()].sort((a, b) => a - b)
     for (const orderedKey of orderedKeys) {
-      await promises.appendFile(`${this.fileUploadPath}/${filePath}`, fileChunks.get(orderedKey) as Uint8Array)
+      const chunk = fileChunks.get(orderedKey)
+      if (!chunk) {
+        throw new Error(`Could not find chunk ${orderedKey} for upload ${uploadId}`)
+      }
+
+      this.logger.debug(`FS writing chunk ${orderedKey} for ${uploadId}: ${JSON.stringify(chunk)}`)
+      await promises.appendFile(`${this.fileUploadPath}/${filePath}`, chunk)
     }
 
     this.inMemoryChunks.delete(uploadId)