mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 09:38:40 +00:00
* fix: use STATE_DIR instead of hardcoded ~/.openclaw for identity and canvas device-identity.ts and canvas-host/server.ts used hardcoded path.join(os.homedir(), '.openclaw', ...) ignoring OPENCLAW_STATE_DIR env var and the resolveStateDir() logic from config/paths.ts. This caused ~/.openclaw/identity and ~/.openclaw/canvas directories to be created even when state dir was overridden or resided elsewhere. * fix: format and remove duplicate imports * fix: scope state-dir patch + add regression tests (#4824) (thanks @kossoy) * fix: align state-dir fallbacks in hooks and agent paths (#4824) (thanks @kossoy) --------- Co-authored-by: Gustavo Madeira Santana <gumadeiras@gmail.com>
30 lines
865 B
TypeScript
30 lines
865 B
TypeScript
type StateDirEnvSnapshot = {
|
|
openclawStateDir: string | undefined;
|
|
clawdbotStateDir: string | undefined;
|
|
};
|
|
|
|
export function snapshotStateDirEnv(): StateDirEnvSnapshot {
|
|
return {
|
|
openclawStateDir: process.env.OPENCLAW_STATE_DIR,
|
|
clawdbotStateDir: process.env.CLAWDBOT_STATE_DIR,
|
|
};
|
|
}
|
|
|
|
export function restoreStateDirEnv(snapshot: StateDirEnvSnapshot): void {
|
|
if (snapshot.openclawStateDir === undefined) {
|
|
delete process.env.OPENCLAW_STATE_DIR;
|
|
} else {
|
|
process.env.OPENCLAW_STATE_DIR = snapshot.openclawStateDir;
|
|
}
|
|
if (snapshot.clawdbotStateDir === undefined) {
|
|
delete process.env.CLAWDBOT_STATE_DIR;
|
|
} else {
|
|
process.env.CLAWDBOT_STATE_DIR = snapshot.clawdbotStateDir;
|
|
}
|
|
}
|
|
|
|
export function setStateDirEnv(stateDir: string): void {
|
|
process.env.OPENCLAW_STATE_DIR = stateDir;
|
|
delete process.env.CLAWDBOT_STATE_DIR;
|
|
}
|