mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 15:48:28 +00:00
refactor(commands): dedupe cleanup path resolution
This commit is contained in:
@@ -29,6 +29,23 @@ export function collectWorkspaceDirs(cfg: OpenClawConfig | undefined): string[]
|
||||
return [...dirs];
|
||||
}
|
||||
|
||||
export function buildCleanupPlan(params: {
|
||||
cfg: OpenClawConfig | undefined;
|
||||
stateDir: string;
|
||||
configPath: string;
|
||||
oauthDir: string;
|
||||
}): {
|
||||
configInsideState: boolean;
|
||||
oauthInsideState: boolean;
|
||||
workspaceDirs: string[];
|
||||
} {
|
||||
return {
|
||||
configInsideState: isPathWithin(params.configPath, params.stateDir),
|
||||
oauthInsideState: isPathWithin(params.oauthDir, params.stateDir),
|
||||
workspaceDirs: collectWorkspaceDirs(params.cfg),
|
||||
};
|
||||
}
|
||||
|
||||
export function isPathWithin(child: string, parent: string): boolean {
|
||||
const relative = path.relative(parent, child);
|
||||
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
||||
|
||||
Reference in New Issue
Block a user