mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
perf(panel): optimize P1 hot paths and consolidate P2 shared primitives
This commit is contained in:
@@ -57,6 +57,7 @@ export function writeTrajectoryCacheFile(filePath, data) {
|
||||
append('}');
|
||||
|
||||
const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
|
||||
let renamed = false;
|
||||
try {
|
||||
const fd = openSync(temporaryPath, 'wx');
|
||||
try {
|
||||
@@ -72,6 +73,7 @@ export function writeTrajectoryCacheFile(filePath, data) {
|
||||
}
|
||||
const written = statSync(temporaryPath, { bigint: true });
|
||||
renameSync(temporaryPath, filePath);
|
||||
renamed = true;
|
||||
const file = statSync(filePath, { bigint: true });
|
||||
lastWritesByPath.delete(filePath);
|
||||
if (isSameFile(written, file)) {
|
||||
@@ -82,6 +84,8 @@ export function writeTrajectoryCacheFile(filePath, data) {
|
||||
lastWritesByPath.set(filePath, { filePath, file, ranges });
|
||||
}
|
||||
} finally {
|
||||
try { unlinkSync(temporaryPath); } catch {}
|
||||
if (!renamed) {
|
||||
try { unlinkSync(temporaryPath); } catch {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user