MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / makeLock

Function makeLock

src/workspaces/process-lock.ts:83–93  ·  view source on GitHub ↗
(lockDir: string, owner: WorkspaceRootLockOwner)

Source from the content-addressed store, hash-verified

81}
82
83function makeLock(lockDir: string, owner: WorkspaceRootLockOwner): WorkspaceProcessLock {
84 return {
85 lockDir,
86 owner,
87 release: async () => {
88 const current = await readOwner(lockDir).catch(() => null)
89 if (current?.token !== owner.token) return
90 await rm(lockDir, { recursive: true, force: true })
91 },
92 }
93}
94
95async function writeOwner(lockDir: string, owner: WorkspaceRootLockOwner): Promise<void> {
96 await writeFile(join(lockDir, OWNER_FILE), JSON.stringify(owner, null, 2) + '\n', 'utf8')

Callers 1

Calls 1

readOwnerFunction · 0.85

Tested by

no test coverage detected