Files
orca/src/main/workspace-snapshot-prune-index.ts
T
mirror 34fa2cd5ca
Skill update round trip / roundtrip (false, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, latest) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
source snapshot 2026-09-02
2026-09-02 02:03:16 +08:00

58 lines
1.6 KiB
TypeScript

import type { ExecutionHostId } from '../shared/execution-host'
export type WorkspaceSnapshotPruneTarget = {
worktreeId: string
executionHostId?: ExecutionHostId
}
export type WorkspaceSnapshotPruneTombstone = WorkspaceSnapshotPruneTarget & {
prunedAt: number
}
export function workspaceSnapshotPruneKey(
worktreeId: string,
executionHostId?: ExecutionHostId
): string {
return `${executionHostId ?? '*'}\0${worktreeId}`
}
export function workspaceSnapshotPruneTargetKeys(
targets: readonly WorkspaceSnapshotPruneTarget[]
): Set<string> {
return new Set(
targets.map(({ worktreeId, executionHostId }) =>
workspaceSnapshotPruneKey(worktreeId, executionHostId)
)
)
}
export function activeWorkspaceSnapshotPruneKeys(
tombstones: ReadonlyMap<string, WorkspaceSnapshotPruneTombstone> | undefined,
scannedAt: number
): Set<string> {
const keys = new Set<string>()
for (const [key, entry] of tombstones ?? []) {
if (entry.prunedAt >= scannedAt) {
keys.add(key)
}
}
return keys
}
export function registerWorkspaceSnapshotPrunesForFile(
tombstonesByFile: Map<string, Map<string, WorkspaceSnapshotPruneTombstone>>,
file: string,
targets: readonly WorkspaceSnapshotPruneTarget[]
): void {
const tombstones = tombstonesByFile.get(file) ?? new Map()
const prunedAt = Date.now()
for (const { worktreeId, executionHostId } of targets) {
tombstones.set(workspaceSnapshotPruneKey(worktreeId, executionHostId), {
worktreeId,
...(executionHostId ? { executionHostId } : {}),
prunedAt
})
}
tombstonesByFile.set(file, tombstones)
}