MCPcopy
hub / github.com/Fission-AI/OpenSpec / withWorksetsLock

Function withWorksetsLock

src/core/worksets.ts:262–277  ·  view source on GitHub ↗
(
  fn: (state: WorksetsState) => T | Promise<T>,
  options: WorksetPathOptions = {}
)

Source from the content-addressed store, hash-verified

260 * .code-workspace coherently; the lock is released before any spawn.
261 */
262export async function withWorksetsLock<T>(
263 fn: (state: WorksetsState) => T | Promise<T>,
264 options: WorksetPathOptions = {}
265): Promise<T> {
266 const lockPath = `${getWorksetsFilePath(options)}.lock`;
267 const lock = await acquireFileLock({
268 lockPath,
269 errorFor: worksetsLockError,
270 });
271
272 try {
273 return await fn(await readWorksetsState(options));
274 } finally {
275 await releaseFileLock(lock, lockPath);
276 }
277}
278
279export function worksetNotFoundError(
280 name: string,

Callers 4

worksets.test.tsFile · 0.85
openMethod · 0.85
updateWorksetsStateFunction · 0.85
removeWorksetFunction · 0.85

Calls 4

getWorksetsFilePathFunction · 0.85
acquireFileLockFunction · 0.85
readWorksetsStateFunction · 0.85
releaseFileLockFunction · 0.85

Tested by

no test coverage detected