chore(log): _boot.log 超过 256KB 只保留最后 64KB(窗口多屏恢复已有中心点校验,无需改)
Verify (Gitea) / gate (build · unit · facts) (push) Successful in 2m0s

This commit is contained in:
qiqi committed 2026-11-17 15:17:12 +08:00
1 parent ce575d2640
commit e9a6402373
1 file changed
+17 -1
+17 -1
View File
@@ -494,7 +494,23 @@
}
// 一次性迁移:把老版本存在 IndexedDB 里的图片字节搬到 images/ 下(跑过一次就写标记文件)
const blog = async (m) => { try { await fs().writeTextFile(await join(dir, '_boot.log'), new Date().toISOString() + ' ' + m + '\n', { append: true }) } catch (e) { /* ignore */ } }
// 启动日志:超过 256KB 只保留最后 64KB(否则长年累月会一直长)
const blog = async (m) => {
try {
const logPath = await join(dir, '_boot.log')
let tail = ''
try {
const st = await fs().stat(logPath)
if (st && st.size > 262144) {
const txt = await fs().readTextFile(logPath)
tail = txt.slice(-65536)
}
} catch (e) { /* 文件不存在就是首次 */ }
const line = new Date().toISOString() + ' ' + m + '\n'
if (tail) await fs().writeTextFile(logPath, tail + line)
else await fs().writeTextFile(logPath, line, { append: true })
} catch (e) { /* ignore */ }
}
async function migrateBlobs() {
try {
await blog('migrate:start dir=' + dir)