fix: use owner-level unidesk state
This commit is contained in:
+6
-5
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
|
||||
import { closeSync, existsSync, ftruncateSync, lstatSync, mkdirSync, opendirSync, openSync, readdirSync, readFileSync, readSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
||||
import { basename, dirname, join, resolve } from "node:path";
|
||||
|
||||
import { type UniDeskConfig, repoRoot, rootPath } from "./config";
|
||||
import { type UniDeskConfig, repoRoot, rootPath, stateRoot } from "./config";
|
||||
import { runRemoteGcCommand } from "./gc-remote";
|
||||
|
||||
type GcRisk = "low" | "medium" | "high" | "blocked";
|
||||
@@ -928,11 +928,12 @@ function yamlStateRoots(value: unknown, label: string): GcPathRoot[] {
|
||||
return Object.entries(record).map(([id, rawPath]) => {
|
||||
if (!/^[a-z0-9._-]+$/iu.test(id)) throw new Error(`${label}.${id} must use a simple id`);
|
||||
const displayPath = yamlString(rawPath, `${label}.${id}`);
|
||||
if (displayPath.startsWith("/") || displayPath.includes("..") || displayPath.includes("\\")) {
|
||||
throw new Error(`${label}.${id} must be a repo-relative .state path without ..`);
|
||||
if (displayPath.includes("..") || displayPath.includes("\\")) {
|
||||
throw new Error(`${label}.${id} must be a canonical state path without ..`);
|
||||
}
|
||||
if (!displayPath.startsWith(".state/")) throw new Error(`${label}.${id} must start with .state/`);
|
||||
return { id, displayPath, path: rootPath(...displayPath.split("/")) };
|
||||
const path = resolvePath(displayPath);
|
||||
if (!path.startsWith(`${stateRoot}/`)) throw new Error(`${label}.${id} must be under ${stateRoot}/`);
|
||||
return { id, displayPath, path };
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user