yusueketk 7 лет назад
Родитель
Сommit
36f43cb48b
2 измененных файлов с 4 добавлено и 3 удалено
  1. 1 1
      src/server/models/attachment.js
  2. 3 2
      src/server/routes/attachment.js

+ 1 - 1
src/server/models/attachment.js

@@ -35,7 +35,7 @@ module.exports = function(crowi) {
     //   2. ensure backward compatibility of data
     //   2. ensure backward compatibility of data
 
 
     // return `/files/${this._id}`;
     // return `/files/${this._id}`;
-    return fileUploader.generateUrl(this.filePath);
+     return fileUploader.generateUrl(this.filePath);
   });
   });
 
 
   attachmentSchema.statics.findById = function(id) {
   attachmentSchema.statics.findById = function(id) {

+ 3 - 2
src/server/routes/attachment.js

@@ -140,8 +140,9 @@ module.exports = function(crowi, app) {
 
 
     var tmpFile = req.file || null;
     var tmpFile = req.file || null;
     const usingFilesSize = await fileUploader.getCollectionSize();
     const usingFilesSize = await fileUploader.getCollectionSize();
-    if (tmpFile.size > usingFilesSize) {
-      throw new Error('mongoDB for file uploading reaches the limit');
+    const usableCapacity = +process.env.GRIDFS_LIMIT - usingFilesSize;
+    if (tmpFile.size > usableCapacity) {
+      throw new Error('mongoDB for file uploading reaches limit');
     }
     }
     debug('Uploaded tmpFile: ', tmpFile);
     debug('Uploaded tmpFile: ', tmpFile);
     if (!tmpFile) {
     if (!tmpFile) {