فهرست منبع

GC-1407: fix bug for uploading file to mongodb with previous version

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

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

@@ -76,7 +76,13 @@ module.exports = function(crowi) {
    * @return {stream.Readable} readable stream
    * @return {stream.Readable} readable stream
    */
    */
   lib.findDeliveryFile = async function(attachment) {
   lib.findDeliveryFile = 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 });
 
 
     if (attachmentFile == null) {
     if (attachmentFile == null) {
       throw new Error(`Any AttachmentFile that relate to the Attachment (${attachment._id.toString()}) does not exist in GridFS`);
       throw new Error(`Any AttachmentFile that relate to the Attachment (${attachment._id.toString()}) does not exist in GridFS`);