mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:50:49 +00:00
[codex] Extract filesystem safety primitives (#77918)
* refactor: extract filesystem safety primitives * refactor: use fs-safe for file access helpers * refactor: reuse fs-safe for media reads * refactor: use fs-safe for image reads * refactor: reuse fs-safe in qqbot media opener * refactor: reuse fs-safe for local media checks * refactor: consume cleaner fs-safe api * refactor: align fs-safe json option names * fix: preserve fs-safe migration contracts * refactor: use fs-safe primitive subpaths * refactor: use grouped fs-safe subpaths * refactor: align fs-safe api usage * refactor: adapt private state store api * chore: refresh proof gate * refactor: follow fs-safe json api split * refactor: follow reduced fs-safe surface * build: default fs-safe python helper off * fix: preserve fs-safe plugin sdk aliases * refactor: consolidate fs-safe usage * refactor: unify fs-safe store usage * refactor: trim fs-safe temp workspace usage * refactor: hide low-level fs-safe primitives * build: use published fs-safe package * fix: preserve outbound recovery durability after rebase * chore: refresh pr checks
This commit is contained in:
committed by
GitHub
parent
61481eb34f
commit
538605ff44
@@ -6,6 +6,7 @@ import {
|
||||
MIGRATION_REASON_MISSING_SOURCE_OR_TARGET,
|
||||
} from "openclaw/plugin-sdk/migration";
|
||||
import type { MigrationItem } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { appendRegularFile, pathExists } from "openclaw/plugin-sdk/security-runtime";
|
||||
import { parse as parseYaml } from "yaml";
|
||||
|
||||
export function resolveHomePath(input: string): string {
|
||||
@@ -19,12 +20,7 @@ export function resolveHomePath(input: string): string {
|
||||
}
|
||||
|
||||
export async function exists(filePath: string): Promise<boolean> {
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return await pathExists(filePath);
|
||||
}
|
||||
|
||||
export async function isDirectory(dirPath: string): Promise<boolean> {
|
||||
@@ -126,7 +122,11 @@ export async function appendItem(item: MigrationItem): Promise<MigrationItem> {
|
||||
const content = await fs.readFile(item.source, "utf8");
|
||||
const header = `\n\n<!-- Imported from Hermes: ${path.basename(item.source)} -->\n\n`;
|
||||
await fs.mkdir(path.dirname(item.target), { recursive: true });
|
||||
await fs.appendFile(item.target, `${header}${content.trimEnd()}\n`, "utf8");
|
||||
await appendRegularFile({
|
||||
filePath: item.target,
|
||||
content: `${header}${content.trimEnd()}\n`,
|
||||
rejectSymlinkParents: true,
|
||||
});
|
||||
return { ...item, status: "migrated" };
|
||||
} catch (err) {
|
||||
return markMigrationItemError(item, err instanceof Error ? err.message : String(err));
|
||||
|
||||
Reference in New Issue
Block a user