فهرست منبع

BugFix: couldn't remove gridfs AttachmentFile which was uploaded by 3.3.x

Yuki Takei 7 سال پیش
والد
کامیت
404a2a7035
1فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 7 1
      src/server/service/file-uploader/gridfs.js

+ 7 - 1
src/server/service/file-uploader/gridfs.js

@@ -22,7 +22,13 @@ module.exports = function(crowi) {
   AttachmentFile.promisifiedWrite = util.promisify(AttachmentFile.write).bind(AttachmentFile);
 
   lib.deleteFile = async function(attachment) {
-    const attachmentFile = await AttachmentFile.findOne({ filename: attachment.fileName });
+    let filenameValue = attachment.fileName;
+
+    if (attachment.filePath != null) {  // backward compatibility for v3.3.x or below
+      filenameValue = attachment.filePath;
+    }
+
+    const attachmentFile = await AttachmentFile.findOne({ filename: filenameValue });
 
     AttachmentFile.unlinkById(attachmentFile._id, function(error, unlinkedFile) {
       if (error) {