mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* fix(cli): retire old snapshot run folders * chore: satisfy snapshot comment limit * fix(history): read and release snapshot leases through verified handles * test(history): run lease races in Node and check released markers * fix(studio): verify snapshot leases from open descriptors
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { resolve } from "node:path";
|
|
import { artifactDirectory, finishSnapshotRun } from "@hyperframes/studio-server/history";
|
|
|
|
const runDirectories = new Map<string, string>();
|
|
const activeChecks = new Map<string, number>();
|
|
|
|
export function beginCheckSnapshots(projectDir: string): void {
|
|
const project = resolve(projectDir);
|
|
activeChecks.set(project, (activeChecks.get(project) ?? 0) + 1);
|
|
}
|
|
|
|
export function checkSnapshotDirectory(projectDir: string): string {
|
|
const project = resolve(projectDir);
|
|
let directory = runDirectories.get(project);
|
|
if (!directory) {
|
|
directory = artifactDirectory(project, "snapshots");
|
|
runDirectories.set(project, directory);
|
|
}
|
|
return directory;
|
|
}
|
|
|
|
export async function finishCheckSnapshots(projectDir: string): Promise<void> {
|
|
const project = resolve(projectDir);
|
|
const remaining = Math.max(0, (activeChecks.get(project) ?? 1) - 1);
|
|
if (remaining > 0) {
|
|
activeChecks.set(project, remaining);
|
|
return;
|
|
}
|
|
activeChecks.delete(project);
|
|
const path = runDirectories.get(project);
|
|
if (!path) return;
|
|
runDirectories.delete(project);
|
|
await finishSnapshotRun(project, path);
|
|
}
|