Преглед изворни кода

Early return if attachHandlers is empty

Shun Miyazawa пре 11 месеци
родитељ
комит
df8c3b9786
1 измењених фајлова са 5 додато и 0 уклоњено
  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;