fix: ensure settings cache is cleared after saving and clearing cache (#326)

This commit is contained in:
samanhappy
2025-09-01 10:15:50 +08:00
committed by GitHub
parent ce15330016
commit a5fc4a429d

View File

@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
import { McpSettings } from '../../types/index.js';
import { getSettingsPath } from '../../config/index.js';
import { getSettingsPath, clearSettingsCache } from '../../config/index.js';
/**
* Abstract base class for JSON file-based DAO implementations
@@ -67,6 +67,8 @@ export abstract class JsonFileBaseDao {
// Update cache
this.settingsCache = settings;
this.lastModified = Date.now();
clearSettingsCache();
} catch (error) {
console.error(`Failed to save settings:`, error);
throw error;
@@ -79,6 +81,7 @@ export abstract class JsonFileBaseDao {
protected clearCache(): void {
this.settingsCache = null;
this.lastModified = 0;
clearSettingsCache();
}
/**