( ids: string[], dir?: string, )
| 229 | * state on that path (tests enforce this). |
| 230 | */ |
| 231 | export async function removeCronTasks( |
| 232 | ids: string[], |
| 233 | dir?: string, |
| 234 | ): Promise<void> { |
| 235 | if (ids.length === 0) return |
| 236 | // Sweep session store first. If every id was accounted for there, we're |
| 237 | // done — skip the file read entirely. removeSessionCronTasks is a no-op |
| 238 | // (returns 0) on miss, so pre-existing durable-delete paths fall through |
| 239 | // without allocating. |
| 240 | if (dir === undefined && removeSessionCronTasks(ids) === ids.length) { |
| 241 | return |
| 242 | } |
| 243 | const idSet = new Set(ids) |
| 244 | const tasks = await readCronTasks(dir) |
| 245 | const remaining = tasks.filter(t => !idSet.has(t.id)) |
| 246 | if (remaining.length === tasks.length) return |
| 247 | await writeCronTasks(remaining, dir) |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Stamp `lastFiredAt` on the given recurring tasks and write back. Batched |
no test coverage detected