فهرست منبع

queue next job on bulk export job finish

Futa Arai 1 سال پیش
والد
کامیت
db7c67a5a0

+ 1 - 1
apps/app/src/features/page-bulk-export/server/service/page-bulk-export/index.ts

@@ -434,7 +434,7 @@ class PageBulkExportService implements IPageBulkExportService {
    * - abort multipart upload
    * - abort multipart upload
    */
    */
   async cleanUpExportJobResources(pageBulkExportJob: PageBulkExportJobDocument, restarted = false) {
   async cleanUpExportJobResources(pageBulkExportJob: PageBulkExportJobDocument, restarted = false) {
-    this.pageBulkExportJobManager.removeJobInProgress(pageBulkExportJob._id, restarted);
+    this.pageBulkExportJobManager.removeJobInProgressAndQueueNextJob(pageBulkExportJob._id, restarted);
 
 
     const promises = [
     const promises = [
       PageBulkExportPageSnapshot.deleteMany({ pageBulkExportJob }),
       PageBulkExportPageSnapshot.deleteMany({ pageBulkExportJob }),

+ 7 - 5
apps/app/src/features/page-bulk-export/server/service/page-bulk-export/page-bulk-export-job-manager.ts

@@ -73,11 +73,13 @@ export class PageBulkExportJobManager {
   removeJobInProgressAndQueueNextJob(jobId: ObjectIdLike, isJobRestarted = false): void {
   removeJobInProgressAndQueueNextJob(jobId: ObjectIdLike, isJobRestarted = false): void {
     this.removeJobInProgress(jobId, isJobRestarted);
     this.removeJobInProgress(jobId, isJobRestarted);
 
 
-    if (this.jobQueue.length > 0 && this.canExecuteNextJob()) {
-      const nextJob = this.jobQueue.shift();
-      if (nextJob != null) {
-        this.jobsInProgress[nextJob.id.toString()] = { stream: undefined };
-        this.pageBulkExportService.executePageBulkExportJob(nextJob);
+    if (this.jobQueue.length > 0) {
+      while (this.canExecuteNextJob()) {
+        const nextJob = this.jobQueue.shift();
+        if (nextJob != null) {
+          this.jobsInProgress[nextJob.id.toString()] = { stream: undefined };
+          this.pageBulkExportService.executePageBulkExportJob(nextJob);
+        }
       }
       }
     }
     }
   }
   }