소스 검색

clean code

zamis 5 년 전
부모
커밋
477b534a2d
1개의 변경된 파일9개의 추가작업 그리고 7개의 파일을 삭제
  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 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;
   }