* Update this session's name in its PID registry file so ListPeers * can surface it. Best-effort: silently no-op if name is falsy, the * file doesn't exist (session not registered), or read/write fails.
(patch: Record<string, unknown>)
| 114 | * file doesn't exist (session not registered), or read/write fails. |
| 115 | */ |
| 116 | async function updatePidFile(patch: Record<string, unknown>): Promise<void> { |
| 117 | const pidFile = join(getSessionsDir(), `${process.pid}.json`) |
| 118 | try { |
| 119 | const data = jsonParse(await readFile(pidFile, 'utf8')) as Record< |
| 120 | string, |
| 121 | unknown |
| 122 | > |
| 123 | await writeFile(pidFile, jsonStringify({ ...data, ...patch })) |
| 124 | } catch (e) { |
| 125 | logForDebugging( |
| 126 | `[concurrentSessions] updatePidFile failed: ${errorMessage(e)}`, |
| 127 | ) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | export async function updateSessionName( |
| 132 | name: string | undefined, |
no test coverage detected