Просмотр исходного кода

refactor: rm shouldEmit arg from ExportService.export

mizozobu 3 лет назад
Родитель
Сommit
ec71d4af3d

+ 2 - 2
packages/app/src/server/service/export.js

@@ -236,7 +236,7 @@ class ExportService {
     // TODO: remove broken zip file
   }
 
-  async export(collections, shouldEmit = true) {
+  async export(collections) {
     if (this.currentProgressingStatus != null) {
       throw new Error('There is an exporting process running.');
     }
@@ -246,7 +246,7 @@ class ExportService {
 
     let zipFileStat;
     try {
-      zipFileStat = await this.exportCollectionsToZippedJson(collections, shouldEmit);
+      zipFileStat = await this.exportCollectionsToZippedJson(collections);
     }
     finally {
       this.currentProgressingStatus = null;

+ 14 - 21
packages/app/src/server/service/g2g-transfer.ts

@@ -310,15 +310,13 @@ export class G2GTransferPusherService implements Pusher {
   }
 
   // eslint-disable-next-line max-len
-  public async startTransfer(tk: TransferKey, user: any, toGROWIInfo: IDataGROWIInfo, collections: string[], optionsMap: any, shouldEmit = true): Promise<void> {
+  public async startTransfer(tk: TransferKey, user: any, toGROWIInfo: IDataGROWIInfo, collections: string[], optionsMap: any): Promise<void> {
     const socket = this.crowi.socketIoService.getAdminSocket();
 
-    if (shouldEmit) {
-      socket.emit('admin:g2gProgress', {
-        mongo: G2G_PROGRESS_STATUS.IN_PROGRESS,
-        attachments: G2G_PROGRESS_STATUS.PENDING,
-      });
-    }
+    socket.emit('admin:g2gProgress', {
+      mongo: G2G_PROGRESS_STATUS.IN_PROGRESS,
+      attachments: G2G_PROGRESS_STATUS.PENDING,
+    });
 
     const targetConfigKeys = uploadConfigKeys;
 
@@ -328,8 +326,7 @@ export class G2GTransferPusherService implements Pusher {
 
     let zipFileStream: ReadStream;
     try {
-      const shouldEmit = false;
-      const zipFileStat = await this.crowi.exportService.export(collections, shouldEmit);
+      const zipFileStat = await this.crowi.exportService.export(collections);
       const zipFilePath = zipFileStat.zipFilePath;
 
       zipFileStream = createReadStream(zipFilePath);
@@ -367,12 +364,10 @@ export class G2GTransferPusherService implements Pusher {
       throw err;
     }
 
-    if (shouldEmit) {
-      socket.emit('admin:g2gProgress', {
-        mongo: G2G_PROGRESS_STATUS.COMPLETED,
-        attachments: G2G_PROGRESS_STATUS.IN_PROGRESS,
-      });
-    }
+    socket.emit('admin:g2gProgress', {
+      mongo: G2G_PROGRESS_STATUS.COMPLETED,
+      attachments: G2G_PROGRESS_STATUS.IN_PROGRESS,
+    });
 
     try {
       await this.transferAttachments(tk);
@@ -387,12 +382,10 @@ export class G2GTransferPusherService implements Pusher {
       throw err;
     }
 
-    if (shouldEmit) {
-      socket.emit('admin:g2gProgress', {
-        mongo: G2G_PROGRESS_STATUS.COMPLETED,
-        attachments: G2G_PROGRESS_STATUS.COMPLETED,
-      });
-    }
+    socket.emit('admin:g2gProgress', {
+      mongo: G2G_PROGRESS_STATUS.COMPLETED,
+      attachments: G2G_PROGRESS_STATUS.COMPLETED,
+    });
   }
 
   /**