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

Method writeConfigWithRetry

zpr/zpr.ts:173–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

171 try {
172 await this.db.write();
173 console.log("[zpr] 配置保存成功");
174 return true;
175 } catch (writeError: any) {
176 console.error(`[zpr] 第${attempt}次写入失败:`, writeError);
177 if (attempt === 5) {
178 // 最后一次失败,尝试恢复备份
179 await this.restoreFromBackup();
180 throw writeError;
181 }
182 await lifecycleDelay(attempt * 200, "zpr:config-write-retry");
183 }
184 }
185 return false;
186 }
187
188 private static async ensureInitialized(): Promise<void> {
189 // 插件重新加载时强制重新初始化以从磁盘加载最新配置
190 if (!this.initialized || !this.db) {
191 await this.init();
192 }
193 }

Callers 1

setProxyHostMethod · 0.95

Calls 4

restoreFromBackupMethod · 0.95
writeMethod · 0.80
errorMethod · 0.80
lifecycleDelayFunction · 0.70

Tested by

no test coverage detected