* Ensures the lock file exists for a task list
(taskListId: string)
| 509 | * Ensures the lock file exists for a task list |
| 510 | */ |
| 511 | async function ensureTaskListLockFile(taskListId: string): Promise<string> { |
| 512 | await ensureTasksDir(taskListId) |
| 513 | const lockPath = getTaskListLockPath(taskListId) |
| 514 | // proper-lockfile requires the target file to exist. Create it with the |
| 515 | // 'wx' flag (write-exclusive) so concurrent callers don't both create it, |
| 516 | // and the first one to create wins silently. |
| 517 | try { |
| 518 | await writeFile(lockPath, '', { flag: 'wx' }) |
| 519 | } catch { |
| 520 | // EEXIST or other — file already exists, which is fine. |
| 521 | } |
| 522 | return lockPath |
| 523 | } |
| 524 | |
| 525 | export type ClaimTaskOptions = { |
| 526 | /** |
no test coverage detected