Browse Source

Early return if attachHandlers is empty

Shun Miyazawa 10 months ago
parent
commit
df8c3b9786
1 changed files with 5 additions and 0 deletions
  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;