From c59d71e6cd84e13d0b37a9e631cbef61c7db2cbf Mon Sep 17 00:00:00 2001 From: luojiyin Date: Thu, 15 Oct 2026 00:10:35 +0800 Subject: [PATCH] docs: explain file sync durability --- src/utils/safe-write-file.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/safe-write-file.ts b/src/utils/safe-write-file.ts index bdacdb5..c12f72d 100644 --- a/src/utils/safe-write-file.ts +++ b/src/utils/safe-write-file.ts @@ -42,6 +42,8 @@ export async function safeWriteFile(filePath: string, content: string) { } await handle.truncate(buf.length); + // 同步写入的数据和截断后的文件长度,再报告修复完成。 + // 同步完成前若发生崩溃,文件仍可能只有部分新内容。 await handle.sync(); } finally { await handle.close();