|
|
@@ -1,6 +1,7 @@
|
|
|
const logger = require('@alias/logger')('growi:service:AttachmentService'); // eslint-disable-line no-unused-vars
|
|
|
|
|
|
const fs = require('fs');
|
|
|
+const mongoose = require('mongoose');
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -45,11 +46,24 @@ class AttachmentService {
|
|
|
|
|
|
async removeAttachment(attachments) {
|
|
|
const { fileUploadService } = this.crowi;
|
|
|
+ const attachmentsCollection = mongoose.connection.collection('attachments');
|
|
|
+ // const attachmentsFilesChunkCollection = mongoose.connection.collection('attachmentFiles.chunks');
|
|
|
+ // const attachmentsFilesFilesColleciton = mongoose.connection.collection('attachmentFiles.files');
|
|
|
+ const unorderAttachmentsBulkOp = attachmentsCollection.initializeUnorderedBulkOp();
|
|
|
+ // const unorderAttachmentsFilesChunkBulkOp = attachmentsFilesChunkCollection.initializeOrderedBulkOp();
|
|
|
+ // const unorderAttachmentsFilesFilesBulkOp = attachmentsFilesFilesColleciton.initializeOrderedBulkOp();
|
|
|
|
|
|
- return attachments.forEach((attachment) => {
|
|
|
+ attachments.forEach((attachment) => {
|
|
|
fileUploadService.deleteFile(attachment);
|
|
|
- attachment.remove();
|
|
|
+ // unorderAttachmentsFilesChunkBulkOp.find({ _id: attachment._id }).remove();
|
|
|
+ // unorderAttachmentsFilesFilesBulkOp.find({ _id: attachment._id }).remove();
|
|
|
+ unorderAttachmentsBulkOp.find({ _id: attachment._id }).remove();
|
|
|
});
|
|
|
+
|
|
|
+ // await unorderAttachmentsFilesChunkBulkOp.execute();
|
|
|
+ // await unorderAttachmentsFilesFilesBulkOp.execute();
|
|
|
+ await unorderAttachmentsBulkOp.execute();
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
}
|