mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 21:10:21 +00:00
refactor: dedupe test and runtime seams
This commit is contained in:
@@ -6,6 +6,7 @@ import type {
|
||||
SandboxFsStat,
|
||||
SandboxResolvedPath,
|
||||
} from "openclaw/plugin-sdk/sandbox";
|
||||
import { resolveWritableRenameTargetsForBridge } from "openclaw/plugin-sdk/sandbox";
|
||||
import type { OpenShellSandboxBackend } from "./backend.js";
|
||||
import { movePathWithCopyFallback } from "./mirror.js";
|
||||
|
||||
@@ -28,6 +29,14 @@ class OpenShellFsBridge implements SandboxFsBridge {
|
||||
private readonly backend: OpenShellSandboxBackend,
|
||||
) {}
|
||||
|
||||
private resolveRenameTargets(params: { from: string; to: string; cwd?: string }) {
|
||||
return resolveWritableRenameTargetsForBridge(
|
||||
params,
|
||||
(target) => this.resolveTarget(target),
|
||||
(target, action) => this.ensureWritable(target, action),
|
||||
);
|
||||
}
|
||||
|
||||
resolvePath(params: { filePath: string; cwd?: string }): SandboxResolvedPath {
|
||||
const target = this.resolveTarget(params);
|
||||
return {
|
||||
@@ -140,12 +149,9 @@ class OpenShellFsBridge implements SandboxFsBridge {
|
||||
cwd?: string;
|
||||
signal?: AbortSignal;
|
||||
}): Promise<void> {
|
||||
const from = this.resolveTarget({ filePath: params.from, cwd: params.cwd });
|
||||
const to = this.resolveTarget({ filePath: params.to, cwd: params.cwd });
|
||||
const { from, to } = this.resolveRenameTargets(params);
|
||||
const fromHostPath = this.requireHostPath(from);
|
||||
const toHostPath = this.requireHostPath(to);
|
||||
this.ensureWritable(from, "rename files");
|
||||
this.ensureWritable(to, "rename files");
|
||||
await assertLocalPathSafety({
|
||||
target: from,
|
||||
root: from.mountHostRoot,
|
||||
|
||||
Reference in New Issue
Block a user