mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:31:23 +00:00
fix(ci): stabilize state-dir dependent tests
This commit is contained in:
@@ -2,25 +2,28 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resolveAgentWorkspaceDir } from "../agents/agent-scope.js";
|
||||
import { STATE_DIR } from "../config/paths.js";
|
||||
import { resolveStateDir } from "../config/paths.js";
|
||||
|
||||
const STATIC_LOCAL_ROOTS = [
|
||||
os.tmpdir(),
|
||||
path.join(STATE_DIR, "media"),
|
||||
path.join(STATE_DIR, "agents"),
|
||||
path.join(STATE_DIR, "workspace"),
|
||||
path.join(STATE_DIR, "sandboxes"),
|
||||
] as const;
|
||||
function buildMediaLocalRoots(stateDir: string): string[] {
|
||||
const resolvedStateDir = path.resolve(stateDir);
|
||||
return [
|
||||
os.tmpdir(),
|
||||
path.join(resolvedStateDir, "media"),
|
||||
path.join(resolvedStateDir, "agents"),
|
||||
path.join(resolvedStateDir, "workspace"),
|
||||
path.join(resolvedStateDir, "sandboxes"),
|
||||
];
|
||||
}
|
||||
|
||||
export function getDefaultMediaLocalRoots(): readonly string[] {
|
||||
return STATIC_LOCAL_ROOTS;
|
||||
return buildMediaLocalRoots(resolveStateDir());
|
||||
}
|
||||
|
||||
export function getAgentScopedMediaLocalRoots(
|
||||
cfg: OpenClawConfig,
|
||||
agentId?: string,
|
||||
): readonly string[] {
|
||||
const roots = [...STATIC_LOCAL_ROOTS];
|
||||
const roots = buildMediaLocalRoots(resolveStateDir());
|
||||
if (!agentId?.trim()) {
|
||||
return roots;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user