zamis 5 лет назад
Родитель
Сommit
8ddb4976d1
1 измененных файлов с 6 добавлено и 6 удалено
  1. 6 6
      src/server/service/file-uploader/gridfs.js

+ 6 - 6
src/server/service/file-uploader/gridfs.js

@@ -47,13 +47,13 @@ module.exports = function(crowi) {
     const filenameValues = attachments.map((attachment) => {
     const filenameValues = attachments.map((attachment) => {
       return attachment.fileName;
       return attachment.fileName;
     });
     });
-    const idsRelatedFiles = await AttachmentFile.find({ filename: { $in: filenameValues } }, { _id: 1 }).map((fileIdObjects) => {
-      return fileIdObjects.map((obj) => { return obj._id });
-    });
+    const fileIdObjects = await AttachmentFile.find({ filename: { $in: filenameValues } }, { _id: 1 });
+    const idsRelatedFiles = fileIdObjects.map((obj) => { return obj._id });
 
 
-    await AttachmentFile.deleteMany({ filename: { $in: filenameValues } });
-    await chunkCollection.deleteMany({ files_id: { $in: idsRelatedFiles } });
-    return;
+    return Promise.all([
+      AttachmentFile.deleteMany({ filename: { $in: filenameValues } }),
+      chunkCollection.deleteMany({ files_id: { $in: idsRelatedFiles } }),
+    ]);
   };
   };
 
 
   /**
   /**