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

Method validateAndRestore

zpr/zpr.ts:110–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

108 const configExists = await fs.access(this.configPath).then(() => true).catch(() => false);
109 if (!configExists) return;
110
111 const configContent = await fs.readFile(this.configPath, 'utf8');
112 JSON.parse(configContent); // 验证JSON格式
113 } catch (error) {
114 console.warn("[zpr] 配置文件损坏,尝试从备份恢复");
115 await this.restoreFromBackup();
116 }
117 }
118
119 private static async restoreFromBackup(): Promise<void> {
120 try {
121 const backupExists = await fs.access(this.backupPath).then(() => true).catch(() => false);
122 if (backupExists) {
123 await fs.copyFile(this.backupPath, this.configPath);
124 console.log("[zpr] 从备份恢复配置成功");

Callers 1

initMethod · 0.95

Calls 2

restoreFromBackupMethod · 0.95
warnMethod · 0.80

Tested by

no test coverage detected