()
| 159 | const configExists = await fs.access(this.configPath).then(() => true).catch(() => false); |
| 160 | if (configExists) { |
| 161 | await fs.copyFile(this.configPath, this.backupPath); |
| 162 | console.log("[zpr] 配置备份创建成功"); |
| 163 | } |
| 164 | } catch (error) { |
| 165 | console.warn("[zpr] 创建备份失败:", error); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | private static async writeConfigWithRetry(): Promise<boolean> { |
| 170 | for (let attempt = 1; attempt <= 5; attempt++) { |
| 171 | try { |
| 172 | await this.db.write(); |
| 173 | console.log("[zpr] 配置保存成功"); |
| 174 | return true; |