Sfoglia il codice sorgente

Early return if attachHandlers is empty

Shun Miyazawa 11 mesi fa
parent
commit
df8c3b9786
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  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;