utsushiiro 7 yıl önce
ebeveyn
işleme
bc0d1a551c

+ 6 - 0
src/server/service/config-loader.js

@@ -122,6 +122,12 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type:    TYPES.NUMBER,
     type:    TYPES.NUMBER,
     default: Infinity,
     default: Infinity,
   },
   },
+  MONGO_GRIDFS_TOTAL_LIMIT: {
+    ns:      'crowi',
+    key:     'gridfs:totalLimit',
+    type:    TYPES.NUMBER,
+    default: Infinity,
+  },
   SAML_USES_ONLY_ENV_VARS_FOR_SOME_OPTIONS: {
   SAML_USES_ONLY_ENV_VARS_FOR_SOME_OPTIONS: {
     ns:      'crowi',
     ns:      'crowi',
     key:     'security:passport-saml:useOnlyEnvVarsForSomeOptions',
     key:     'security:passport-saml:useOnlyEnvVarsForSomeOptions',

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

@@ -62,13 +62,9 @@ module.exports = function(crowi) {
       return { isUploadable: false, errorMessage: 'File size exceeds the size limit per file' };
       return { isUploadable: false, errorMessage: 'File size exceeds the size limit per file' };
     }
     }
 
 
-    // skip checking if env var is undefined
-    if (process.env.MONGO_GRIDFS_TOTAL_LIMIT == null) {
-      return { isUploadable: true };
-    }
-
     const usingFilesSize = await getCollectionSize();
     const usingFilesSize = await getCollectionSize();
-    if (usingFilesSize + uploadFileSize > +process.env.MONGO_GRIDFS_TOTAL_LIMIT) {
+    const gridfsTotalLimit = crowi.configManager.getConfig('crowi', 'gridfs:totalLimit');
+    if (usingFilesSize + uploadFileSize > gridfsTotalLimit) {
       return { isUploadable: false, errorMessage: 'MongoDB for uploading files reaches limit' };
       return { isUploadable: false, errorMessage: 'MongoDB for uploading files reaches limit' };
     }
     }