Răsfoiți Sursa

Merge branch 'feat/78040-135788-resume-suspended-bulk-export-job' into feat/78039-135789-delete-unnecessary-page-bulk-export-jobs

Futa Arai 1 an în urmă
părinte
comite
3e3ba7d1de

+ 1 - 0
apps/app/src/features/page-bulk-export/interfaces/page-bulk-export.ts

@@ -25,6 +25,7 @@ export interface IPageBulkExportJob {
   page: Ref<IPage>, // the root page of page tree to export
   lastExportedPagePath?: string, // the path of page that was exported to the fs last
   uploadId?: string, // upload ID of multipart upload of S3/GCS
+  uploadKey?: string, // upload key of multipart upload of S3/GCS
   format: PageBulkExportFormat,
   completedAt?: Date, // the date at which job was completed
   attachment?: Ref<IAttachment>,

+ 1 - 0
apps/app/src/features/page-bulk-export/server/models/page-bulk-export-job.ts

@@ -14,6 +14,7 @@ const pageBulkExportJobSchema = new Schema<PageBulkExportJobDocument>({
   page: { type: Schema.Types.ObjectId, ref: 'Page', required: true },
   lastExportedPagePath: { type: String },
   uploadId: { type: String, unique: true, sparse: true },
+  uploadKey: { type: String, unique: true, sparse: true },
   format: { type: String, enum: Object.values(PageBulkExportFormat), required: true },
   completedAt: { type: Date },
   attachment: { type: Schema.Types.ObjectId, ref: 'Attachment' },

+ 3 - 2
apps/app/src/features/page-bulk-export/server/service/page-bulk-export.ts

@@ -264,13 +264,14 @@ class PageBulkExportService {
 
     const fileUploadService: FileUploader = this.crowi.fileUploadService;
     // if the process of uploading was interrupted, delete and start from the start
-    if (pageBulkExportJob.uploadId != null) {
-      await fileUploadService.abortExistingMultipartUpload(uploadKey, pageBulkExportJob.uploadId);
+    if (pageBulkExportJob.uploadKey != null && pageBulkExportJob.uploadId != null) {
+      await fileUploadService.abortExistingMultipartUpload(pageBulkExportJob.uploadKey, pageBulkExportJob.uploadId);
     }
 
     // init multipart upload
     const multipartUploader: IMultipartUploader = fileUploadService.createMultipartUploader(uploadKey, this.maxPartSize);
     await multipartUploader.initUpload();
+    pageBulkExportJob.uploadKey = uploadKey;
     pageBulkExportJob.uploadId = multipartUploader.uploadId;
     await pageBulkExportJob.save();