MCPcopy Create free account
hub / github.com/Rfym21/Qwen2API / _ensureDataFileExists

Method _ensureDataFileExists

src/utils/data-persistence.js:333–353  ·  view source on GitHub ↗

* 确保数据文件存在 * @private

()

Source from the content-addressed store, hash-verified

331 return false
332 }
333
334 // 替换 pending payload 与 timer
335 this._statsPendingPayload.set(email, stats)
336 const prev = this._statsPersistTimers.get(email)
337 if (prev) clearTimeout(prev)
338
339 const timer = setTimeout(async () => {
340 this._statsPersistTimers.delete(email)
341 const payload = this._statsPendingPayload.get(email)
342 this._statsPendingPayload.delete(email)
343 if (!payload) return
344 try {
345 await this.saveAccount(email, { stats: payload })
346 } catch (error) {
347 logger.error(`stats 持久化失败 (${email})`, 'STATS', '', error)
348 }
349 }, STATS_PERSIST_DEBOUNCE_MS)
350
351 this._statsPersistTimers.set(email, timer)
352 return true
353 }
354
355 /**
356 * 读取并解析 data.json;解析失败时尝试用备份自愈

Callers 5

_loadSettingsFromFileMethod · 0.95
_saveSettingsToFileMethod · 0.95
_loadFromFileMethod · 0.95
_saveToFileMethod · 0.95
_saveAllToFileMethod · 0.95

Calls 2

infoMethod · 0.80
successMethod · 0.80

Tested by

no test coverage detected