瀏覽代碼

Server - Fixed - Use file path instead buffer to reduce memory usage on EXIF extraction (#545)

fix undefined exif data
Thanh Pham 2 年之前
父節點
當前提交
dfaa4969da
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      server/apps/microservices/src/processors/metadata-extraction.processor.ts

+ 4 - 3
server/apps/microservices/src/processors/metadata-extraction.processor.ts

@@ -50,10 +50,11 @@ export class MetadataExtractionProcessor {
   async extractExifInfo(job: Job<IExifExtractionProcessor>) {
     try {
       const { asset, fileName, fileSize }: { asset: AssetEntity; fileName: string; fileSize: number } = job.data;
+      const exifData = await exifr.parse(asset.originalPath);
 
-      const fileBuffer = await readFile(asset.originalPath);
-
-      const exifData = await exifr.parse(fileBuffer);
+      if (!exifData) {
+        throw new Error(`can not fetch exif data from file ${asset.originalPath}`);
+      }
 
       const newExif = new ExifEntity();
       newExif.assetId = asset.id;