Group repeat pseudonymization runs by project path

This commit is contained in:
muena
2026-09-25 16:17:03 +02:00
parent c3ef1a6aed
commit 5877b7cf5f
4 changed files with 91 additions and 15 deletions

View File

@@ -39,8 +39,12 @@ const EXCLUDES = new Set([".git", "node_modules", "dist", "build", "out", ".next
".venv", "venv", "__pycache__", "target", "vendor", "coverage", ".cache", ".turbo",
".idea", ".vscode", "Pods", "DerivedData"]);
export function canonicalProjectPath(path: string): string {
return resolve(path);
}
function projectIdFor(path: string): string {
return createHash("sha1").update(path.replace(/\/+$/, "")).digest("hex").slice(0, 16);
return createHash("sha1").update(canonicalProjectPath(path)).digest("hex").slice(0, 16);
}
async function isBinary(path: string): Promise<boolean> {
@@ -245,6 +249,7 @@ export function safeRelativePath(path: string): string {
export async function createRun(projectPath: string, support = environment.supportPath): Promise<{
run: ProjectRun; directory: string;
}> {
projectPath = canonicalProjectPath(projectPath);
const id = `${new Date().toISOString().replace(/[:.]/g, "-")}-${randomUUID().slice(0, 8)}`;
const directory = join(projectDataRoot(projectPath, support), "runs", id);
await fs.mkdir(join(directory, "files"), { recursive: true, mode: 0o700 });
@@ -278,7 +283,9 @@ export async function listRuns(projectPath: string, support = environment.suppor
const directory = join(root, entry.name);
try {
const run = JSON.parse(await fs.readFile(join(directory, "run.json"), "utf8")) as ProjectRun;
if (run.version === 2 && run.projectPath === projectPath) runs.push({ run, directory });
if (run.version === 2 && canonicalProjectPath(run.projectPath) === canonicalProjectPath(projectPath)) {
runs.push({ run, directory });
}
} catch { /* incomplete run: not offered for restoration */ }
}
return runs.sort((a, b) => b.run.createdAt.localeCompare(a.run.createdAt));