From e9a6402373070edc88d7cf3449d33d7098fcd294 Mon Sep 17 00:00:00 2001 From: qiqi Date: Tue, 17 Nov 2026 15:17:12 +0800 Subject: [PATCH] =?UTF-8?q?chore(log):=20=5Fboot.log=20=E8=B6=85=E8=BF=87?= =?UTF-8?q?=20256KB=20=E5=8F=AA=E4=BF=9D=E7=95=99=E6=9C=80=E5=90=8E=2064KB?= =?UTF-8?q?=EF=BC=88=E7=AA=97=E5=8F=A3=E5=A4=9A=E5=B1=8F=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E5=B7=B2=E6=9C=89=E4=B8=AD=E5=BF=83=E7=82=B9=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E9=9C=80=E6=94=B9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/storage-file.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/storage-file.js b/src/storage-file.js index 61f57fa..2bce871 100644 --- a/src/storage-file.js +++ b/src/storage-file.js @@ -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)