zamis 5 lat temu
rodzic
commit
477b534a2d
1 zmienionych plików z 9 dodań i 7 usunięć
  1. 9 7
      src/server/service/attachment.js

+ 9 - 7
src/server/service/attachment.js

@@ -48,15 +48,17 @@ class AttachmentService {
     const attachmentsCollection = mongoose.connection.collection('attachments');
     const attachmentsCollection = mongoose.connection.collection('attachments');
     const unorderAttachmentsBulkOp = attachmentsCollection.initializeUnorderedBulkOp();
     const unorderAttachmentsBulkOp = attachmentsCollection.initializeUnorderedBulkOp();
 
 
-    if (attachments.length > 0) {
-      fileUploadService.deleteFiles(attachments);
-
-      attachments.forEach((attachment) => {
-        unorderAttachmentsBulkOp.find({ _id: attachment._id }).remove();
-      });
-      await unorderAttachmentsBulkOp.execute();
+    if (attachments.length === 0) {
+      return;
     }
     }
 
 
+    fileUploadService.deleteFiles(attachments);
+
+    attachments.forEach((attachment) => {
+      unorderAttachmentsBulkOp.find({ _id: attachment._id }).remove();
+    });
+    await unorderAttachmentsBulkOp.execute();
+
     return;
     return;
   }
   }