Yuki Takei 1 год назад
Родитель
Сommit
6eb275aa77
1 измененных файлов с 20 добавлено и 8 удалено
  1. 20 8
      apps/app/src/server/service/config-manager/config-manager.ts

+ 20 - 8
apps/app/src/server/service/config-manager/config-manager.ts

@@ -94,19 +94,33 @@ export class ConfigManager implements IConfigManagerForApp, S2sMessageHandlable
         : (this.dbConfig[key] ?? this.envConfig[key])?.value;
         : (this.dbConfig[key] ?? this.envConfig[key])?.value;
     })() as ConfigValues[K];
     })() as ConfigValues[K];
 
 
+    this.checkDifference(key, value);
+
+    return value;
+  }
+
+  private checkDifference<K extends ConfigKey>(key: K, value: ConfigValues[K], source?: ConfigSource): void {
     const valueByLegacy = (() => {
     const valueByLegacy = (() => {
       if (source === ConfigSource.env) {
       if (source === ConfigSource.env) {
-        return configManagerLegacy.getConfigFromEnvVars(ns, key);
+        return configManagerLegacy.getConfigFromEnvVars('crowi', key);
       }
       }
       if (source === ConfigSource.db) {
       if (source === ConfigSource.db) {
-        return configManagerLegacy.getConfigFromDB(ns, key);
+        return configManagerLegacy.getConfigFromDB('crowi', key);
       }
       }
-      return configManagerLegacy.getConfig(ns, key);
+      return configManagerLegacy.getConfig('crowi', key);
     })();
     })();
 
 
-    const isDifferent = Array.isArray(value)
-      ? value.length !== valueByLegacy.length || value.some((v, i) => v !== valueByLegacy[i])
-      : value !== valueByLegacy;
+    const isDifferent = (() => {
+      if (Array.isArray(value)) {
+        return value.length !== valueByLegacy.length || value.some((v, i) => v !== valueByLegacy[i]);
+      }
+
+      if (typeof value === 'object') {
+        return JSON.stringify(value) !== JSON.stringify(valueByLegacy);
+      }
+
+      return value !== valueByLegacy;
+    })();
 
 
     if (isDifferent) {
     if (isDifferent) {
       if (!(value === undefined && valueByLegacy === null)) {
       if (!(value === undefined && valueByLegacy === null)) {
@@ -116,8 +130,6 @@ export class ConfigManager implements IConfigManagerForApp, S2sMessageHandlable
         );
         );
       }
       }
     }
     }
-
-    return value;
   }
   }
 
 
   private shouldUseEnvOnly(key: ConfigKey): boolean {
   private shouldUseEnvOnly(key: ConfigKey): boolean {