Browse Source

Early return if attachHandlers is empty

Shun Miyazawa 1 năm trước cách đây
mục cha
commit
df8c3b9786
1 tập tin đã thay đổi với 5 bổ sung0 xóa
  1. 5 0
      apps/app/src/server/service/attachment.js

+ 5 - 0
apps/app/src/server/service/attachment.js

@@ -56,6 +56,11 @@ class AttachmentService {
       await fileUploadService.uploadAttachment(readStreamForCreateAttachmentDocument, attachment);
       await attachment.save();
 
+      if (this.attachHandlers.length === 0) {
+        disposeTmpFileCallback?.(file);
+        return attachment;
+      }
+
       const readStreamForAttacheHandler = createReadStream(file.path);
       const chunks = [];
       const attachHandlers = this.attachHandlers;