mirror of
https://github.com/margrop/wrong-notebook.git
synced 2026-12-05 09:19:24 +08:00
chore: 消除 background-tasks 的 Turbopack 文件追踪警告
This commit is contained in:
@@ -142,7 +142,7 @@ function ensureLoaded() {
|
||||
if (!file) return;
|
||||
let saved: unknown;
|
||||
try {
|
||||
saved = JSON.parse(fs.readFileSync(file, 'utf8'));
|
||||
saved = JSON.parse(fs.readFileSync(/* turbopackIgnore: true */ file, 'utf8'));
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') logger.warn({ error }, 'Failed to read saved background tasks');
|
||||
return;
|
||||
@@ -173,11 +173,11 @@ function saveNow() {
|
||||
// 唯一临时名,避免并发/多次写盘共用同一路径;失败时清理残留临时文件
|
||||
const temp = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
fs.writeFileSync(temp, JSON.stringify([...tasks.values()]));
|
||||
fs.renameSync(temp, file);
|
||||
fs.mkdirSync(/* turbopackIgnore: true */ path.dirname(/* turbopackIgnore: true */ file), { recursive: true });
|
||||
fs.writeFileSync(/* turbopackIgnore: true */ temp, JSON.stringify([...tasks.values()]));
|
||||
fs.renameSync(/* turbopackIgnore: true */ temp, /* turbopackIgnore: true */ file);
|
||||
} catch (error) {
|
||||
fs.rmSync(temp, { force: true });
|
||||
fs.rmSync(/* turbopackIgnore: true */ temp, { force: true });
|
||||
logger.warn({ error }, 'Failed to save background tasks');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user