MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / downloadConfigFile

Function downloadConfigFile

fadian/fadian.ts:67–81  ·  view source on GitHub ↗
(filename: string)

Source from the content-addressed store, hash-verified

65 configCache[filename] = Array.isArray(response.data) ? response.data : [];
66 } catch (error) {
67 console.error(`下载配置文件失败: ${filename}`, error);
68 }
69}
70
71// 确保配置文件存在并是最新的
72async function ensureConfigFile(filename: string): Promise<string[]> {
73 const localPath = path.join(ASSET_PATH, filename);
74 const now = Date.now();
75
76 // 检查是否需要更新
77 if (!fs.existsSync(localPath) || now - lastUpdateCheck > UPDATE_INTERVAL) {
78 await downloadConfigFile(filename);
79 lastUpdateCheck = now;
80 }
81
82 // 从缓存获取,如果缓存为空则从文件读取
83 if (!configCache[filename] && fs.existsSync(localPath)) {
84 configCache[filename] = readJsonArray(localPath);

Callers 1

ensureConfigFileFunction · 0.85

Calls 2

errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected