mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 18:40:42 +00:00
Refactor file access to use fs-safe primitives (#78255)
* refactor: use fs-safe primitives across file access * fix: preserve invalid managed npm manifests * fix: keep fs seams for startup metadata
This commit is contained in:
committed by
GitHub
parent
0d73f174a9
commit
b85b1c68d1
@@ -28,6 +28,7 @@ import {
|
||||
} from "../../daemon/service.js";
|
||||
import { createLowDiskSpaceWarning } from "../../infra/disk-space.js";
|
||||
import { pathExists } from "../../infra/fs-safe.js";
|
||||
import { readJsonIfExists, writeJson } from "../../infra/json-files.js";
|
||||
import { runGlobalPackageUpdateSteps } from "../../infra/package-update-steps.js";
|
||||
import { getSelfAndAncestorPidsSync } from "../../infra/restart-stale-pids.js";
|
||||
import { nodeVersionSatisfiesEngine } from "../../infra/runtime-guard.js";
|
||||
@@ -1702,15 +1703,14 @@ async function writePostCorePluginUpdateResultFile(
|
||||
if (!filePath) {
|
||||
return;
|
||||
}
|
||||
await fs.writeFile(filePath, `${JSON.stringify(result)}\n`, "utf-8");
|
||||
await writeJson(filePath, result, { trailingNewline: true });
|
||||
}
|
||||
|
||||
async function readPostCorePluginUpdateResultFile(
|
||||
filePath: string,
|
||||
): Promise<PostCorePluginUpdateResult | undefined> {
|
||||
try {
|
||||
const raw = await fs.readFile(filePath, "utf-8");
|
||||
const parsed = JSON.parse(raw) as PostCorePluginUpdateResult;
|
||||
const parsed = await readJsonIfExists<PostCorePluginUpdateResult>(filePath);
|
||||
if (
|
||||
parsed &&
|
||||
typeof parsed === "object" &&
|
||||
|
||||
Reference in New Issue
Block a user